public void ExpressionReturnsTrueWhenSpecifactionIsFalse(TestObject testObject, bool result)
        {
            var specification1 = new ExpressionSpecification <TestObject>(p => p.BooleanProperty);

            var notSpecification = new NotSpecification <TestObject>(specification1);

            ExpressionSpecificationTester.TestSpecification(notSpecification, testObject, result);
        }
Beispiel #2
0
        public void ExpressionReturnsTrueWhenAllSpecifactionsAreTrue(TestObject testObject, bool result)
        {
            var specification1 = new ExpressionSpecification <TestObject>(p => p.BooleanProperty);
            var specification2 = new ExpressionSpecification <TestObject>(p => p.BooleanProperty1);

            var andSpecification = new AndSpecification <TestObject>(specification1, specification2);

            ExpressionSpecificationTester.TestSpecification(andSpecification, testObject, result);
        }
Beispiel #3
0
        public void ExpressionReturnsTrueWhenAnySpecifactionIsTrue(TestObject testObject, bool expectedResult)
        {
            var specification1 = new ExpressionSpecification <TestObject>(p => p.BooleanProperty);
            var specification2 = new ExpressionSpecification <TestObject>(p => p.BooleanProperty1);

            var orSpecification = new OrSpecification <TestObject>(specification1, specification2);

            ExpressionSpecificationTester.TestSpecification(orSpecification, testObject, expectedResult);
        }
        public void EmptySpecificationCreatesTrueSpecification()
        {
            var testObject = new TestObject();

            var specification = new TestObjectSpecification();

            var expectedResult = true;

            ExpressionSpecificationTester.TestSpecification(specification, testObject, expectedResult);
        }
        public void WhenSpecificationForCollectionAllIsEmptyOmitSpecification()
        {
            var testObject = new TestObject();

            var specification = new TestObjectSpecification()
                                .CollectionAll(p => { });

            var expectedResult = true;

            ExpressionSpecificationTester.TestSpecification(specification, testObject, expectedResult);
        }
        public void WhenSpecificationForPropertyIsEmptyOmitSpecification()
        {
            var testObject = new TestObject();

            var specification = new TestObjectSpecification()
                                .ByProperty(p => {});

            var expectedResult = true;

            ExpressionSpecificationTester.TestSpecification(specification, testObject, expectedResult);
        }
        public void WhereAddsSingleSpecification()
        {
            var testObject = new TestObject()
            {
                BooleanProperty = true
            };

            var specification = new TestObjectSpecification().BooleanProperty(true);

            var expectedResult = true;

            ExpressionSpecificationTester.TestSpecification(specification, testObject, expectedResult);
        }
        public void AllowsApplySpecificationForDerivedObjects()
        {
            var testObject = new DerivedFromTestObject()
            {
                AdditionalProperty = true
            };

            var specification = new TestObjectSpecification()
                                .ByDerived(p => p.AdditionalProperty(true));

            var expectedResult = true;

            ExpressionSpecificationTester.TestSpecification(specification, testObject, expectedResult);
        }
        public void NotNegateSpecification()
        {
            var testObject = new TestObject()
            {
                BooleanProperty = false
            };

            var specification = new TestObjectSpecification()
                                .Not(p => p.BooleanProperty(true));

            var expectedResult = true;

            ExpressionSpecificationTester.TestSpecification(specification, testObject, expectedResult);
        }
        public void OrNotCombineSpecificationsByNegatedDisjunction()
        {
            var testObject = new TestObject()
            {
                BooleanProperty  = false,
                BooleanProperty1 = true
            };

            var specification = new TestObjectSpecification()
                                .BooleanProperty(true).OrNot(or => or.BooleanProperty1(false));

            var expectedResult = true;

            ExpressionSpecificationTester.TestSpecification(specification, testObject, expectedResult);
        }
        public void WhereCombineSpecificationsByConjunction()
        {
            var testObject = new TestObject()
            {
                BooleanProperty  = true,
                BooleanProperty1 = true
            };

            var specification = new TestObjectSpecification()
                                .BooleanProperty(true)
                                .BooleanProperty1(true);

            var expectedResult = true;

            ExpressionSpecificationTester.TestSpecification(specification, testObject, expectedResult);
        }
        public void OrNotWithManyParametersCombinePreviousWithExistingSpecificationByByNegatedConjunction()
        {
            var testObject = new TestObject()
            {
                BooleanProperty  = false,
                BooleanProperty1 = true
            };

            var specification = new TestObjectSpecification()
                                .BooleanProperty(false)
                                .OrNot(or => or.BooleanProperty1(false), or => or.BooleanProperty1(false));

            var expectedResult = true;

            ExpressionSpecificationTester.TestSpecification(specification, testObject, expectedResult);
        }
        public void AllowsPropertyToBeFilteredBySpecification()
        {
            var testObject = new TestObject()
            {
                Property = new TestObject()
                {
                    BooleanProperty = true
                }
            };

            var specification = new TestObjectSpecification()
                                .ByProperty(p => p.BooleanProperty(true));

            var expectedResult = true;

            ExpressionSpecificationTester.TestSpecification(specification, testObject, expectedResult);
        }
        public void AllowsCollectionToBeFilteredBySpecificationWithAnyOperator()
        {
            var testObject = new TestObject()
            {
                Collection = new List <TestObject>()
                {
                    new TestObject()
                    {
                        BooleanProperty = true
                    }
                }
            };

            var specification = new TestObjectSpecification()
                                .CollectionAny(p => p.BooleanProperty(true));

            var expectedResult = true;

            ExpressionSpecificationTester.TestSpecification(specification, testObject, expectedResult);
        }
Beispiel #15
0
        public void ExpressionReturnsTrueWhenAllObjectInCollectionSatisfiesExpression(TestObject testObject, bool result)
        {
            var specification = new PropertyAllSpecification <TestObject, TestObject>(p => p.Collection, new ExpressionSpecification <TestObject>(p => p.BooleanProperty));

            ExpressionSpecificationTester.TestSpecification(specification, testObject, result);
        }
        public void ExpressionReturnsCorrectResult(TestObject testObject, bool result)
        {
            var specification = new PropertySpecification <TestObject, TestObject>(p => p.Property, new ExpressionSpecification <TestObject>(p => p.BooleanProperty));

            ExpressionSpecificationTester.TestSpecification(specification, testObject, result);
        }