示例#1
0
            public void InvokeNull_NotRaiseException()
            {
                var left  = MockComplexSpecification.True();
                var right = MockComplexSpecification.True();
                var sut   = new AndSpecification <object>(left, right);

                var exception = Record.Exception(() => sut.GetExpression().Compile().Invoke(null));

                Assert.Null(exception);
            }
示例#2
0
            public void InvokeIncorrectData_ReturnFalse(bool leftResult, bool rightResult)
            {
                var left  = MockComplexSpecification.Create(leftResult);
                var right = MockComplexSpecification.Create(rightResult);
                var sut   = new AndSpecification <object>(left, right);

                var result = sut.GetExpression().Compile().Invoke(new object());

                Assert.False(result);
            }
示例#3
0
            public void NonGenericILinqSpecification_ReturnExpressionAsAbstractExpression()
            {
                var left  = MockSpecification.True();
                var right = MockSpecification.True();
                var sut   = new AndSpecification <object>(left, right);

                var expected = sut.GetExpression();
                var result   = ((ILinqSpecification)sut).GetExpression();

                Assert.Equal(expected, result);
            }
示例#4
0
            public void CastCorrectSpecification_ReturnAndExpression()
            {
                var left  = MockSpecification.True();
                var right = MockSpecification.True();
                var sut   = new AndSpecification <object>(left, right);

                var expected = sut.GetExpression();
                var result   = (Expression)sut;

                Assert.Equal(expected, result);
            }
示例#5
0
            public void CorrectSpecifications_ReturnAndExpression()
            {
                var left  = MockSpecification.True();
                var right = MockSpecification.True();
                var sut   = new AndSpecification <object>(left, right);

                var expression = sut.GetExpression();
                var result     = expression.ToString();

                Assert.Matches(@"candidate => \(.*\.IsSatisfiedBy\(candidate\) AndAlso .*.IsSatisfiedBy\(candidate\)\)",
                               result);
            }
示例#6
0
            public void DifferentTypesSpecifications_ReplaceCandidateParameterToObjInExpression()
            {
                var left  = MockComplexSpecification.True();
                var right = MockSpecification.True();
                var sut   = new AndSpecification <object>(left, right);

                var expression = sut.GetExpression();
                var result     = expression.ToString();

                Assert.Matches(
                    @"obj => \(value\(FluentSpecification.Core.Tests.Mocks.TrueMockComplexSpecification\).IsSatisfiedBy\(obj\) AndAlso .*\.IsSatisfiedBy\(obj\)\)",
                    result);
            }
示例#7
0
            public void InvokeRelatedTypes_NoException()
            {
                var left = MockSpecification <IEnumerable <char> > .True();

                var right = MockSpecification <ChildFakeType> .True();

                var exception = Record.Exception(() =>
                {
                    var sut = new AndSpecification <ChildFakeType>(left, right);
                    sut.GetExpression().Compile().Invoke(new ChildFakeType());
                });

                Assert.Null(exception);
            }