|
|
@ -1042,6 +1042,9 @@ namespace xUnitStudy.WebApi.Test
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region DoesNotContain 类似Contain 略过
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region InRange
|
|
|
|
#region InRange
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
@ -1062,6 +1065,59 @@ namespace xUnitStudy.WebApi.Test
|
|
|
|
|
|
|
|
|
|
|
|
Assert.InRange(person2, person1, person3, comparer);
|
|
|
|
Assert.InRange(person2, person1, person3, comparer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region NotInRange
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void NotInRange_Test()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Assert.NotInRange<int>(5, 10, 100);
|
|
|
|
|
|
|
|
Assert.NotInRange(20, 100, 2000);
|
|
|
|
|
|
|
|
Assert.NotInRange("a", "b", "d");
|
|
|
|
|
|
|
|
Assert.NotInRange("z", "b", "d");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void NotInRange_IComparable_Test()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
IComparer<Person> comparer = new Person();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Person person1 = new Person() { Id = 1 };
|
|
|
|
|
|
|
|
Person person2 = new Person() { Id = 2 };
|
|
|
|
|
|
|
|
Person person3 = new Person() { Id = 3 };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.NotInRange(person1, person2, person3, comparer);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Throws
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void Throw_Exception_Test()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Assert.ThrowsAsync<ArgumentNullException>(()=> { throw new ArgumentNullException("message"); });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void NotThrow_Exception_Test()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//2.0及更高版本,移除了 NotThrow断言
|
|
|
|
|
|
|
|
//使用TryCatch替代或自定断言扩展
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Exception exception = null;
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//dosomething
|
|
|
|
|
|
|
|
exception = null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
exception = ex;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.Null(exception);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
|