public void Try_ShouldThrowInvalidOperationExceptionWhenTryToAddRepeatedBehavior()
        {
            // arrange
            var       helper   = new ExceptionHelper();
            Exception current  = null;
            var       expected = new Exception("Test exception");

            helper.AddBehaviorFor(typeof(Exception), (e) => current = e);


            // act
            Assert.Throws <InvalidOperationException>(() =>
                                                      helper.AddBehaviorFor(typeof(Exception), (e) => current = e));
        }
        public void Try_ShouldPassOriginalExceptionParameter()
        {
            // arrange
            var       helper   = new ExceptionHelper();
            Exception current  = null;
            var       expected = new Exception("Test exception");

            helper.AddBehaviorFor(typeof(Exception), (e) => current = e);

            // act
            helper.Try(() => throw expected);

            // assert
            Assert.That(current, Is.EqualTo(expected));
        }
        public void Try_ShouldExecuteExceptionCode()
        {
            // arrange
            var helper   = new ExceptionHelper();
            var current  = false;
            var expected = true;

            helper.AddBehaviorFor(typeof(Exception), (e) => current = true);

            // act
            helper.Try(() => throw new Exception());

            // assert
            Assert.That(current, Is.EqualTo(expected));
        }
        public void Try_ShouldExecuteExceptionCodeIfExceptionTypeIsUnknown()
        {
            // arrange
            var helper   = new ExceptionHelper();
            var current  = false;
            var expected = true;

            helper.AddBehaviorFor <Exception>((e) => current = true);

            // act
            helper.Try(() => throw new ArgumentException());

            // assert
            Assert.That(current, Is.EqualTo(expected));
        }