Beispiel #1
0
        public void ContinueCheckingStrategiesAfterBeingHandled()
        {
            var counter = 0;
            var context = new ErrorHandlingContext(this, ErrorSeverityLevel.NonFatal, new Exception());

            var strategy1 = new Mock <IErrorHandlingStrategy>();

            strategy1.Setup(o => o.Handle(context)).Callback(() =>
            {
                context.MarkErrorAsHandled();
                counter++;
            });

            var strategy2 = new Mock <IErrorHandlingStrategy>();

            strategy2.Setup(o => o.Handle(context)).Callback(() =>
            {
                counter++;
            });

            var target = new CompositeErrorHandlingStrategy();

            target.AddStrategy(strategy1.Object);
            target.AddStrategy(strategy2.Object);

            target.Handle(context);

            Assert.AreEqual(2, counter);
        }
Beispiel #2
0
        public void ShouldNotRethrowTheExceptionOnceHandledTest()
        {
            var target = new ErrorHandlingContext(this, ErrorSeverityLevel.NonFatal, new Exception());

            target.MarkErrorAsHandled();
            Assert.DoesNotThrow(() => target.RethrowErrorIfNotHandled());
        }