Esempio n. 1
0
        public void EfConfigRepositoryFactory_Using_Ioc_Should_Not_Require_ConnectionString()
        {
            var config  = new EfRepositoryConfiguration("TestConfig", null, typeof(TestObjectEntities));
            var factory = new EfConfigRepositoryFactory(config);

            factory.GetInstance <Contact, string>();
        }
        public void EfConfigRepositoryFactory_Using_Ioc_Should_Not_Require_ConnectionString()
        {
            var config = new EfRepositoryConfiguration("TestConfig", null, typeof (TestObjectEntities));
            var factory = new EfConfigRepositoryFactory(config);

            factory.GetInstance<Contact, string>();
        }
        public void EfConfigRepositoryFactory_Using_Ioc_Should_Return_TestObjectEntites_Without_DbContextType_Defined()
        {
            var config = new EfRepositoryConfiguration("TestConfig");
            var factory = new EfConfigRepositoryFactory(config);

            var repos = factory.GetInstance<Contact, string>();

            var propInfo = repos.GetType().GetProperty("Context", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
            var dbContext = (TestObjectEntities)propInfo.GetValue(repos, null);
            dbContext.ShouldBeType<TestObjectEntities>();
        }
Esempio n. 4
0
        public void EfConfigRepositoryFactory_Using_Ioc_Should_Return_TestObjectEntites_Without_DbContextType_Defined()
        {
            var config  = new EfRepositoryConfiguration("TestConfig");
            var factory = new EfConfigRepositoryFactory(config);

            var repos = factory.GetInstance <Contact, string>();

            var propInfo  = repos.GetType().GetProperty("Context", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
            var dbContext = (TestObjectEntities)propInfo.GetValue(repos, null);

            dbContext.ShouldBeType <TestObjectEntities>();
        }
Esempio n. 5
0
        public void EfConfigRepositoryFactory_Using_Ioc_Should_Share_DbContext()
        {
            var config  = new EfRepositoryConfiguration("TestConfig", "tmp", typeof(TestObjectEntities));
            var factory = new EfConfigRepositoryFactory(config);

            var repos1 = factory.GetInstance <Contact, string>();
            var repos2 = factory.GetInstance <Contact, string>();

            // use reflecton to get the protected Context property
            var propInfo1  = repos1.GetType().GetProperty("Context", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
            var dbContext1 = (TestObjectEntities)propInfo1.GetValue(repos1, null);
            var propInfo2  = repos2.GetType().GetProperty("Context", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
            var dbContext2 = (TestObjectEntities)propInfo2.GetValue(repos2, null);

            dbContext1.ShouldEqual(dbContext2);
        }
        public void EfConfigRepositoryFactory_Using_Ioc_Should_Share_DbContext()
        {
            var config = new EfRepositoryConfiguration("TestConfig", "tmp", typeof (TestObjectEntities));
            var factory = new EfConfigRepositoryFactory(config);

            var repos1 = factory.GetInstance<Contact, string>();
            var repos2 = factory.GetInstance<Contact, string>();

            // use reflecton to get the protected Context property
            var propInfo1 = repos1.GetType().GetProperty("Context", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
            var dbContext1 = (TestObjectEntities)propInfo1.GetValue(repos1, null);
            var propInfo2 = repos2.GetType().GetProperty("Context", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
            var dbContext2 = (TestObjectEntities)propInfo2.GetValue(repos2, null);

            dbContext1.ShouldEqual(dbContext2);
        }