Example #1
0
        public void AllowsCollectionToBeFilteredBySpecificationWithAllOperator()
        {
            var testObject = new TestObject()
            {
                Collection = new List <TestObject>()
                {
                    new TestObject()
                    {
                        BooleanProperty = true
                    },
                    new TestObject()
                    {
                        BooleanProperty = true
                    }
                }
            };

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

            var expectedResult = true;

            EFCoreSpecificationTester.TestSpecification(specification, testObject, expectedResult);
        }
        public void EntityFrameworkSpecificationTest(TestObject testObject, bool result)
        {
            var specification = new AndSpecification <TestObject>(
                new EF.PropertyAnySpecification <TestObject, TestObject>(p => p.Collection, new ExpressionSpecification <TestObject>(p => p.BooleanProperty)),
                new EF.PropertyAllSpecification <TestObject, TestObject>(p => p.Collection, new ExpressionSpecification <TestObject>(p => p.BooleanProperty)));

            EFCoreSpecificationTester.TestSpecification(specification, testObject, result);
        }
Example #3
0
        public void WhenSpecificationForCollectionAllIsEmptyOmitSpecification()
        {
            var testObject = new TestObject();

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

            var expectedResult = true;

            EFCoreSpecificationTester.TestSpecification(specification, testObject, expectedResult);
        }
Example #4
0
        public void WhenSpecificationForPropertyIsEmptyOmitSpecification()
        {
            var testObject = new TestObject();

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

            var expectedResult = true;

            EFCoreSpecificationTester.TestSpecification(specification, testObject, expectedResult);
        }
Example #5
0
        public void AllowsPropertyToBeFilteredBySpecification()
        {
            var testObject = new TestObject()
            {
                Property = new TestObject()
                {
                    BooleanProperty = true
                }
            };

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

            var expectedResult = true;

            EFCoreSpecificationTester.TestSpecification(specification, testObject, expectedResult);
        }