public void That_HaveThreeBooleanInsideAssertBlock_BothConditionsAreTested()
        {
            AssertBuilderFactoryForTests.FakeAssertBuilder();


            var b1 = DummyCreator.GetTrueBooleanValue();
            var b2 = DummyCreator.GetTrueBooleanValue();
            var b3 = DummyCreator.GetTrueBooleanValue();

            Expect.That(() => b1 && b2 && b3);

            var assertBuilder = AssertBuilderFactory.GetAssertBuilder();

            A.CallTo(() => assertBuilder.GetIsTrueAction(A <Expression> ._, A <string> ._)).MustHaveHappened(Repeated.Exactly.Times(3));
        }
Example #2
0
        public static void All(params Action[] assertionsToRun)
        {
            var errorMessages = new List <Exception>();

            foreach (var action in assertionsToRun)
            {
                try
                {
                    action.Invoke();
                }
                catch (Exception exc)
                {
                    errorMessages.Add(exc);
                }
            }

            if (errorMessages.Count <= 0)
            {
                return;
            }

            var errorText = new StringBuilder();

            foreach (var e in errorMessages)
            {
                if (errorText.Length > 0)
                {
                    errorText.Append(Environment.NewLine);
                }

                errorText.Append(digestStackTrace(e));
            }

            var assertBuilder = AssertBuilderFactory.GetAssertBuilder();

            var errorMessage = string.Format("{0}/{1} conditions failed:{2}{2}{3}", errorMessages.Count, assertionsToRun.Length, Environment.NewLine, errorText);

            assertBuilder.GetFail(errorMessage).Compile().Invoke();
        }
        public Expression <Action> GetAction(Expression expression)
        {
            var methodCallExpr = (MethodCallExpression)expression;

            return(AssertBuilderFactory.GetAssertBuilder().GetCollectionContains(methodCallExpr.Object, methodCallExpr.Arguments[0], string.Empty));
        }
Example #4
0
        public Expression <Action> GetAction(Expression expression)
        {
            var methodCallExpr = (MethodCallExpression)expression;

            return(AssertBuilderFactory.GetAssertBuilder().GetCollectionContains(methodCallExpr.Arguments[0], methodCallExpr.Arguments[1], methodCallExpr.PrettyPrint()));
        }