Esempio n. 1
0
        public void GenericOkResult_IsSuccessDoesNotThrowException()
        {
            var       result    = ActResult.Ok(0);
            var       underTest = new AssertionRoot <int>(result);
            Exception exception = null;

            try
            {
                underTest.IsSuccess();
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            Assert.IsNull(exception);
        }
Esempio n. 2
0
        public void GenericErrorResult_ThrewExceptionDoesNotThrowException()
        {
            var       result    = ActResult.ThrewException <int>(new Exception());
            var       underTest = new AssertionRoot <int>(result);
            Exception exception = null;

            try
            {
                underTest.ThrewException();
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            Assert.IsNull(exception);
        }
Esempio n. 3
0
        public void GenericErrorResult_IsSuccessThrowsException()
        {
            var       result    = ActResult.ThrewException <int>(new Exception());
            var       underTest = new AssertionRoot <int>(result);
            Exception exception = null;

            try
            {
                underTest.IsSuccess();
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            Assert.IsNotNull(exception);
            Assert.IsInstanceOfType(exception, typeof(AssertFailedException));
        }
Esempio n. 4
0
        public void ErrorResult_IsSuccessThrowsExceptionWithMessage()
        {
            const string message   = "Should work";
            var          result    = ActResult.ThrewException(new Exception());
            var          underTest = new AssertionRoot(result);
            Exception    exception = null;

            try
            {
                underTest.IsSuccess(message);
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            Assert.IsTrue(exception.Message.Contains(message));
        }
Esempio n. 5
0
        public void GenericErrorResult_ValidateThrowsException()
        {
            var       result    = ActResult.ThrewException <int>(new IOException());
            var       underTest = new AssertionRoot <int>(result);
            Exception exception = null;

            try
            {
                underTest.Validate(r => Assert.AreEqual(1, r));
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            Assert.IsNotNull(exception);
            Assert.IsInstanceOfType(exception, typeof(AssertFailedException));
        }
Esempio n. 6
0
        public void GenericOkResult_ValidationCallbackThrowsException()
        {
            var       result    = ActResult.Ok(1);
            var       underTest = new AssertionRoot <int>(result);
            Exception exception = null;

            try
            {
                underTest.Validate(r => Assert.AreEqual(2, r));
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            Assert.IsNotNull(exception);
            Assert.IsInstanceOfType(exception, typeof(AssertFailedException));
        }
Esempio n. 7
0
        public void GenericOkResult_ValidationCallbackDoesNotThrowException()
        {
            const int one       = 1;
            var       result    = ActResult.Ok(one);
            var       underTest = new AssertionRoot <int>(result);
            Exception exception = null;

            try
            {
                underTest.Validate(r => Assert.AreEqual(one, r));
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            Assert.IsNull(exception);
        }
Esempio n. 8
0
        public void GenericErrorResultWithWrongExceptionType_ThrewExceptionThrowsException()
        {
            var       result    = ActResult.ThrewException <int>(new IOException());
            var       underTest = new AssertionRoot <int>(result);
            Exception exception = null;

            try
            {
                underTest.ThrewException <InvalidOperationException>();
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            Assert.IsNotNull(exception);
            Assert.IsInstanceOfType(exception, typeof(AssertFailedException));
        }
Esempio n. 9
0
        public void OkResult_ThrewExceptionThrowsException()
        {
            var       result    = ActResult.Ok();
            var       underTest = new AssertionRoot(result);
            Exception exception = null;

            try
            {
                underTest.ThrewException();
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            Assert.IsNotNull(exception);
            Assert.IsInstanceOfType(exception, typeof(AssertFailedException));
        }
Esempio n. 10
0
        public void ErrorResultWithWrongExceptionType_ThrewExceptionThrowsExceptionWithMessage()
        {
            const string message   = "Should throw InvalidOperation";
            var          result    = ActResult.ThrewException(new IOException());
            var          underTest = new AssertionRoot(result);
            Exception    exception = null;

            try
            {
                underTest.ThrewException <InvalidOperationException>(message);
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            Assert.IsNotNull(exception);
            Assert.IsInstanceOfType(exception, typeof(AssertFailedException));
        }
Esempio n. 11
0
        public void GenericOkResult_ThrewExceptionThrowsExceptionWithMessage()
        {
            const string message = "Should not work";

            var       result    = ActResult.Ok(0);
            var       underTest = new AssertionRoot <int>(result);
            Exception exception = null;

            try
            {
                underTest.ThrewException(message);
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            Assert.IsTrue(exception.Message.Contains(message));
        }