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

            Assert.True(val);
        }
Beispiel #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());
        }
Beispiel #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());
        }
Beispiel #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());
        }
Beispiel #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"));
        }
Beispiel #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"));
        }
Beispiel #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"));
        }
Beispiel #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"));
        }
        public void Matches_should_detect_non_empty_nominal()
        {
            var subj = new ThrowsMatcher();

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