Beispiel #1
0
        public static void TestSpecification(ISpecification <TestObject> specification, TestObject testObject, bool result)
        {
            using (var sqLiteConnection = new SQLiteConnection("data source=:memory:;cache=shared"))
            {
                sqLiteConnection.Open();
                using (var context = new TestContext(sqLiteConnection))
                {
                    context.Database.Initialize(true);
                    context.TestObjects.Add(testObject);
                    context.SaveChanges();

                    var results = context.TestObjects.Where(specification).SingleOrDefault();
                    if (result)
                    {
                        results.ShouldNotBeNull();
                    }
                    else
                    {
                        results.ShouldBeNull();
                    }
                }
            }
        }
        public void EntityFrameworkSpecificationTest(TestObject testObject, bool result)
        {
            var specification = new Specification.EF.PropertyAnySpecification <TestObject, TestObject>(p => p.Collection, new ExpressionSpecification <TestObject>(p => p.BooleanProperty));

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