Beispiel #1
0
        public void Interface_Realization_Works_For_EF()
        {
            var entities = new List <TestEntity>()
            {
                new TestEntity()
                {
                    Key = "first second", Data = "def"
                },
                new TestEntity()
                {
                    Key = "QueenP", Data = "def"
                },
            };

            var insertContext = new TestDbContext();

            insertContext.Database.EnsureDeleted();
            insertContext.Database.EnsureCreated();

            insertContext.Entities.AddRange(entities);
            insertContext.SaveChanges();

            var readContext        = new TestDbContext();
            IEntityRepository repo = new EntityRepository(readContext);

            IInterfaceWithFunction impl = new ImplementationOfInterfaceWithFunction("first");

            var actual = repo.Entities.Where(e => e.Key == impl.Function("second")).ToArray();

            Assert.True(actual.Count() == 1);
        }
Beispiel #2
0
        public void InterfaceConstantsAreRealizedCorrectly()
        {
            IInterfaceWithFunction impl = new ImplementationOfInterfaceWithFunction("def");

            Expression <Func <string> > exBasedOnInterface = () => impl.Function("abc");

            InlineAndCheckExpression(exBasedOnInterface);
        }