Beispiel #1
0
        public void ExecuteWithoutTask_NoCondition_NoExceptionCaught()
        {
            // ARRANGE
            Exception exception       = null;
            var       objectUnderTest = new ExceptionHandlingOnAsyncVoid.MyAsyncCommand();

            // ACT
            try
            {
                objectUnderTest.ExecuteWithoutTask("some argument");
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            // ASSERT
            Assert.IsNull(exception, "exception is not null.");
        }
Beispiel #2
0
        public void ExecuteWithoutTask_UseNitoAsyncContext_ExceptionCaught()
        {
            // ARRANGE
            Exception exception       = null;
            var       objectUnderTest = new ExceptionHandlingOnAsyncVoid.MyAsyncCommand();

            // ACT
            try
            {
                AsyncContext.Run(() => objectUnderTest.ExecuteWithoutTask("some argument"));
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            // ASSERT
            Assert.NotNull(exception, "exception is null.");
            Assert.IsInstanceOf <InvalidOperationException>(exception, "exception has unexpected type.");
        }
Beispiel #3
0
        public async void InnerExecute_NoCondition_ThrowsException()
        {
            // ARRANGE
            Exception exception       = null;
            var       objectUnderTest = new ExceptionHandlingOnAsyncVoid.MyAsyncCommand();

            // ACT
            try
            {
                await objectUnderTest.InnerExecute("some argument");
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            // ASSERT
            Assert.NotNull(exception, "exception is null.");
            Assert.IsInstanceOf <InvalidOperationException>(exception, "exception has unexpected type.");
        }