Example #1
0
        public void Matches_should_detect_empty_nominal()
        {
            var subj = new ThrowsMatcher();
            var val  = subj.Matches(ThrowingMethod);

            Assert.True(val);
        }
Example #2
0
        public void No_match_if_thrown_exception_does_not_match_predicate()
        {
            var matcher = new ThrowsMatcher <ArgumentNullException>().With(e => e.Message == "something else");

            var matches = matcher.Matches(DoIt);

            NHAssert.That(matches, Is.False());
        }
Example #3
0
        public void No_match_if_action_throws_different_exception()
        {
            var matcher = new ThrowsMatcher <NullReferenceException>();

            var match = matcher.Matches(DoIt);

            NHAssert.That(match, Is.False());
        }
Example #4
0
        public void No_match_if_action_does_not_throw()
        {
            var matcher = new ThrowsMatcher <ArgumentException>();

            var match = matcher.Matches(() => { });

            NHAssert.That(match, Is.False());
        }
Example #5
0
        public void Describe_mismatch_if_thrown_exception_does_not_match_predicate()
        {
            var matcher     = new ThrowsMatcher <ArgumentNullException>().With(e => e.Message == "something else");
            var description = new StringDescription();

            matcher.DescribeMismatch(DoIt, description);

            NHAssert.That(description.ToString(), Starts.With("the exception was of the correct type, but did not match the predicate"));
        }
Example #6
0
        public void Describe_mismatch_if_action_throws_different_exception()
        {
            var matcher     = new ThrowsMatcher <NullReferenceException>();
            var description = new StringDescription();

            matcher.DescribeMismatch(DoIt, description);

            NHAssert.That(description.ToString(), Starts.With("an exception of type System.ArgumentNullException was thrown"));
        }
Example #7
0
        public void Describe_mismatch_if_action_does_not_throw()
        {
            var matcher     = new ThrowsMatcher <ArgumentException>();
            var description = new StringDescription();

            matcher.DescribeMismatch(() => { }, description);

            NHAssert.That(description.ToString(), Is.EqualTo("no exception was thrown"));
        }
Example #8
0
        public void Describe_matcher()
        {
            var matcher     = new ThrowsMatcher <ArgumentNullException>();
            var description = new StringDescription();

            matcher.DescribeTo(description);

            NHAssert.That(description.ToString(), Is.EqualTo("the block to throw an exception of type System.ArgumentNullException"));
        }
Example #9
0
        public void Matches_should_detect_non_empty_nominal()
        {
            var subj = new ThrowsMatcher();

            Assert.False(subj.Matches(NonThrowingMethod));
        }