public void EntityFrameworkRepositoryTests_SaveAggregateRootTest()
        {
            EFCustomer customer = new EFCustomer
            {
                Address = new EFAddress("China", "SH", "SH", "A street", "12345"),
                UserName = "******",
                Password = "******"
            };

            IRepository<EFCustomer> customerRepository = ServiceLocator.Instance.GetService<IRepository<EFCustomer>>();
            customerRepository.Add(customer);
            customerRepository.Context.Commit();
            customerRepository.Context.Dispose();

            int expected = 1;
            int actual = Helper.ReadRecordCountFromEFTestDB(Helper.EF_Table_EFCustomers);
            Assert.AreEqual(expected, actual);
        }
Exemple #2
0
        public async Task EntityFrameworkRepositoryTests_SaveAndLoadAggregateRootTestAsync()
        {
            EFCustomer customer = new EFCustomer
            {
                Address = new EFAddress("China", "SH", "SH", "A street", "12345"),
                UserName = "******",
                Password = "******"
            };
            IRepository<EFCustomer> customerRepository = ServiceLocator.Instance.GetService<IRepository<EFCustomer>>();
            customerRepository.Add(customer);
            await customerRepository.Context.CommitAsync();
            var key = customer.ID;
            EFCustomer customer2 = customerRepository.GetByKey(key);
            customerRepository.Context.Dispose();

            Assert.AreEqual(customer.UserName, customer2.UserName);
            Assert.AreEqual(customer.Password, customer2.Password);
            Assert.AreEqual(customer.Address.City, customer2.Address.City);
            Assert.AreEqual(customer.Address.Country, customer2.Address.Country);
            Assert.AreEqual(customer.Address.State, customer2.Address.State);
            Assert.AreEqual(customer.Address.Street, customer2.Address.Street);
            Assert.AreEqual(customer.Address.Zip, customer2.Address.Zip);
        }
Exemple #3
0
        public async Task EntityFrameworkRepositoryTests_SaveAggregateRootWithIDReturnedTestAsync()
        {
            EFCustomer customer = new EFCustomer
            {
                Address = new EFAddress("China", "SH", "SH", "A street", "12345"),
                UserName = "******",
                Password = "******"
            };

            IRepository<EFCustomer> customerRepository = ServiceLocator.Instance.GetService<IRepository<EFCustomer>>();
            customerRepository.Add(customer);
            await customerRepository.Context.CommitAsync();
            customerRepository.Context.Dispose();

            Assert.AreNotEqual(0, customer.ID);
        }