diff --git a/xUnitStudy.WebApi.Test/UseXUnitAssertTest.cs b/xUnitStudy.WebApi.Test/UseXUnitAssertTest.cs index 03a6086..31870d9 100644 --- a/xUnitStudy.WebApi.Test/UseXUnitAssertTest.cs +++ b/xUnitStudy.WebApi.Test/UseXUnitAssertTest.cs @@ -1042,6 +1042,9 @@ namespace xUnitStudy.WebApi.Test } #endregion + #region DoesNotContain 类似Contain 略过 + #endregion + #region InRange [Fact] @@ -1062,6 +1065,59 @@ namespace xUnitStudy.WebApi.Test Assert.InRange(person2, person1, person3, comparer); } + + #endregion + + #region NotInRange + [Fact] + public void NotInRange_Test() + { + Assert.NotInRange(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 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(()=> { 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 [Fact]