public void Test_GetUnitOfWork() { IUnitOfWork unite = IocManager.Instance.Resolve <IUnitOfWork>(); CustomerDbContext context = unite.Cast <EfUnitOfWork>().GetOrCreateDbContext <CustomerDbContext>(); Assert.IsNotNull(context); }
public void Test_GetDbContext() { using (CustomerDbContext context = IocManager.Instance.Resolve <CustomerDbContext>()) { Customer customer = context.Customers.FirstOrDefault(c => c.Id == 2L); Assert.IsNotNull(customer); Assert.AreEqual(customer.Phone, "13145626325"); Customer c2 = context.Set <Customer>().FirstOrDefault(c => c.Id == 2); Assert.IsNotNull(customer); Assert.AreEqual(customer.Phone, "13145626325"); } }