コード例 #1
0
ファイル: AssertExTests.cs プロジェクト: Lashas83/NHamcrest
 public void One_more()
 {
     Assert.That(() => { throw new InvalidOperationException(); }, Throws.An <NotSupportedException>());
 }
コード例 #2
0
        public void CalculateFinalPriceShouldThrowNullReferenceExceptionIfProvidedProductIsNull()
        {
            void CallingCalculateFinalPriceWithPassedNullProductModel() => Algorithm.CalculateFinalPrice(null, _state, 1);

            Assert.That(CallingCalculateFinalPriceWithPassedNullProductModel, Throws.An <NullReferenceException>());
        }
コード例 #3
0
ファイル: AssertExTests.cs プロジェクト: mminns/NHamcrest
 public void One_more()
 {
     Assert.That(() => { throw new InvalidOperationException(); }, Throws.An <AccessViolationException>());
 }
コード例 #4
0
 public void Throw_if_name_is_too_long()
 {
     Assert.That(() => new BinaryAttachment("aVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString", MimeTypes.Png, new byte[0]),
                 Throws.An <ArgumentException>()
                 .With(e => e.Message == "name must be 100 chars or less\r\nParameter name: name" && e.ParamName == "name"));
 }
コード例 #5
0
ファイル: ThrowsTests.cs プロジェクト: Lashas83/NHamcrest
 public void Match_if_action_throws_superclass_of_expected_exception()
 {
     NHAssert.That(() => DoIt(), Throws.An <ArgumentException>());
 }
コード例 #6
0
ファイル: ThrowsTests.cs プロジェクト: Lashas83/NHamcrest
 public void Match_if_thrown_exception_matches_predicate()
 {
     NHAssert.That(DoIt, Throws.An <ArgumentNullException>().With(e => e.Message == "message" &&
                                                                  e.InnerException.GetType() == typeof(Exception)));
 }
コード例 #7
0
 public void ToString_WhenTokenIsInvalid_ThrowsException(int token)
 {
     Assert.That(() => Token.ToString(token), Throws.An <ArgumentException>());
 }
コード例 #8
0
ファイル: ThrowsTests.cs プロジェクト: Lashas83/NHamcrest
 public void Match_if_action_throws_expected_exception()
 {
     NHAssert.That(() => DoIt(), Throws.An <ArgumentNullException>());
 }
コード例 #9
0
 public void Constructor_WhenErrorLoggerIsNull_ThrowsException()
 {
     Assert.That(
         () => new Parser(Helpers.CreateTextScanner(string.Empty), null), Throws.An <ArgumentNullException>());
 }
コード例 #10
0
 public void Constructor_WhenScannerIsNull_ThrowsException()
 {
     Assert.That(() => new Parser(null, null), Throws.An <ArgumentNullException>());
 }
コード例 #11
0
 public void Constructor_WhenErrorLoggerIsNull_ThrowsException()
 {
     Assert.That(() => new Scanner(string.Empty, null), Throws.An <ArgumentNullException>());
 }
コード例 #12
0
 public void Parse_WhenFormatIsNull_ThrowsException()
 {
     Assert.That(() => Format.Parse(null), Throws.An <ArgumentNullException>());
 }
コード例 #13
0
 public void Evaluate_WhenFormatIsNull_ThrowsException()
 {
     Assert.That(() => Format.Evaluate((string)null), Throws.An <ArgumentNullException>());
 }
コード例 #14
0
 public void Constructor_WhenTextIsNull_ThrowsException()
 {
     Assert.That(() => new TokenInfo(Location.Unknown, Token.Invalid, null), Throws.An <ArgumentNullException>());
 }
コード例 #15
0
 public void Constructor_WhenLocationIsNull_ThrowsException()
 {
     Assert.That(() => new TokenInfo(null, Token.Invalid, string.Empty), Throws.An <ArgumentNullException>());
 }