Exemplo n.º 1
0
        public void GenericOkResult_AssertionCallbackIsCalled()
        {
            var  input     = ActResult.Ok(1);
            var  underTest = new Acted <int>(input);
            bool called    = false;

            underTest.Assert(r => called = true);

            Assert.IsTrue(called);
        }
Exemplo n.º 2
0
        public void OkResult_EmptyAssertReturnsAssertionRoot()
        {
            var input     = ActResult.Ok();
            var underTest = new Acted(input);

            var result = underTest.Assert();

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(AssertionRoot));
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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));
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        public void GenericOkResult_ThrewExceptionThrowsException()
        {
            var       result    = ActResult.Ok(0);
            var       underTest = new AssertionRoot <int>(result);
            Exception exception = null;

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

            Assert.IsNotNull(exception);
            Assert.IsInstanceOfType(exception, typeof(AssertFailedException));
        }
Exemplo n.º 7
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));
        }