public void TryFinally_NoExceptionThrown()
        {
            // arrange
            var query = new Mock<ITestExceptionQuery>();
            var target = new TryFinallyTarget(query.Object);

            // act
            target.TryFinally();

            // assert
            query.Verify(x => x.InFinally(), Times.Once());
        }
        public void TryFinally_ExceptionThrown()
        {
            // arrange
            var query = new Mock<ITestExceptionQuery>();
            query.Setup(x => x.ThrowException()).Callback(() => { throw new InvalidOperationException(); });
            var target = new TryFinallyTarget(query.Object);

            // act
            Assert.Catch<InvalidOperationException>(target.TryFinally);

            // assert
            query.Verify(x => x.InFinally(), Times.Once());
        }
Example #3
0
 protected override void OnStart(string[] args)
 {
     var target = new TryFinallyTarget(new CustomExceptionQuery());
     target.TryFinally();
 }