Ejemplo n.º 1
0
        public void SetupRepository()
        {
            queries = new List <string>();
            var dbPath = EfDataDirectoryFactory.Build();

            dbContext = new TestObjectEntities("Data Source=" + dbPath);

            const int totalItems = 5;

            for (int i = 1; i <= totalItems; i++)
            {
                dbContext.Contacts.Add(
                    new Contact
                {
                    ContactId      = i.ToString(),
                    Name           = "Test User " + i,
                    EmailAddresses = new List <EmailAddress> {
                        new EmailAddress {
                            ContactId      = i.ToString(),
                            EmailAddressId = i,
                            Email          = "omar.piani." + i.ToString() + "@email.com",
                            Label          = "omar.piani." + i.ToString()
                        }
                    }
                });
            }

            dbContext.SaveChanges();

            // reistantiate in order to lose caches
            dbContext = new TestObjectEntities("Data Source=" + dbPath);
        }
Ejemplo n.º 2
0
        public void LazyLoad_Set_To_False()
        {
            var dbPath = EfDataDirectoryFactory.Build();

            Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0");

            var dbContext = new TestObjectEntities("Data Source=" + dbPath);

            dbContext.Configuration.LazyLoadingEnabled = false;

            var repos = new MyEfRepository(dbContext);

            repos.LazyLoadValue.ShouldBeFalse();
        }