public void TaskCatchFinally_1()
        {
            // Setup
            var mock = new Mock <ITryCatchFinally>();
            var m    = mock.Object;

            // Act
            Try.CatchFinally <InvalidCastException>(m.Try, m.Catch, m.Finally);

            // Assert
            mock.Verify(m => m.Try(), Times.Once);
            mock.Verify(m => m.Catch(It.IsAny <InvalidCastException>()), Times.Never);
            mock.Verify(m => m.Finally(), Times.Once);
        }
        public void TaskCatchFinally_2()
        {
            // Setup
            var ex   = new Exception();
            var mock = new Mock <ITryCatchFinally>();

            mock.Setup(m => m.Try()).Throws(ex);

            var m = mock.Object;

            // Act
            Try.CatchFinally(m.Try, m.Catch, m.Finally);

            // Assert
            mock.Verify(m => m.Try(), Times.Once);
            mock.Verify(m => m.Catch(It.IsAny <Exception>()), Times.Once);
            mock.Verify(m => m.Finally(), Times.Once);
        }
        public void TaskCatchFinally_2()
        {
            // Setup
            var ex   = new InvalidCastException();
            var mock = new Mock <ITryCatchFinally>();

            mock.Setup(m => m.Try()).Throws(ex);

            var m = mock.Object;

            // Act
            Try.CatchFinally <InvalidCastException>(m.Try, m.Catch, m.Finally);

            // Assert
            mock.Verify(m => m.Try(), Times.Once);
            mock.Verify(
                m => m.Catch(It.Is <InvalidCastException>(e => ReferenceEquals(e, ex))),
                Times.Once);
            mock.Verify(m => m.Finally(), Times.Once);
        }