コード例 #1
0
        public void when_matching_exception_is_thrown_by_inside_behavior_it_should_be_handled()
        {
            var cut = new TestInterceptExceptionBehavior <ArgumentException>
            {
                InsideBehavior = new ThrowingBehavior <ArgumentException>()
            };

            cut.Invoke();

            cut.HandledException.ShouldBeOfType <ArgumentException>();
        }
コード例 #2
0
        public void when_no_exception_is_thrown_none_should_be_handled()
        {
            var insideBehavior = new DoNothingBehavior();
            var cut            = new TestInterceptExceptionBehavior <ArgumentException>
            {
                InsideBehavior = insideBehavior
            };

            cut.Invoke();

            cut.HandledException.ShouldBeNull();
        }
コード例 #3
0
        public void should_invoke_inside_behavior()
        {
            var insideBehavior = new DoNothingBehavior();
            var cut            = new TestInterceptExceptionBehavior <ArgumentException>
            {
                InsideBehavior = insideBehavior
            };

            cut.Invoke();

            insideBehavior.Invoked.ShouldBeTrue();
        }
コード例 #4
0
        public void when_non_matching_exception_is_thrown_should_handled_should_not_be_invoked()
        {
            var cut = new TestInterceptExceptionBehavior <ArgumentException>
            {
                InsideBehavior = new ThrowingBehavior <WebException>()
            };

            cut.SetShouldHandle(false);

            typeof(WebException).ShouldBeThrownBy(cut.Invoke);

            cut.HandledException.ShouldBeNull();
        }
コード例 #5
0
        public void when_exception_should_not_be_handled_the_handle_method_should_not_be_invoked()
        {
            var cut = new TestInterceptExceptionBehavior <ArgumentException>
            {
                InsideBehavior = new ThrowingBehavior <ArgumentException>()
            };

            cut.SetShouldHandle(false);

            Exception <ArgumentException> .ShouldBeThrownBy(cut.Invoke);

            cut.HandledException.ShouldBeNull();
        }
コード例 #6
0
        public void invoke_should_throw_an_exception_when_no_inside_behavior_is_set()
        {
            var interceptExceptionBehavior = new TestInterceptExceptionBehavior <ArgumentException>();

            typeof(FubuAssertionException).ShouldBeThrownBy(interceptExceptionBehavior.Invoke);
        }
コード例 #7
0
        public void invoke_should_throw_an_exception_when_no_inside_behavior_is_set()
        {
            var interceptExceptionBehavior = new TestInterceptExceptionBehavior <ArgumentException>();

            Exception <FubuAssertionException> .ShouldBeThrownBy(() => interceptExceptionBehavior.Invoke().Wait());
        }