Ejemplo n.º 1
0
 public void Can_Get_Customers_From_Database()
 {
     using (var repo = new RepositoryFactory().Create())
     {
         var customers = repo.All <Customer>().ToList();
         CollectionAssert.IsNotEmpty(customers);
     }
 }
Ejemplo n.º 2
0
 public void Can_Get_Customers_From_Database()
 {
     using (var repo = new RepositoryFactory().Create())
     {
         var customers = repo.All<Customer>().ToList();
         CollectionAssert.IsNotEmpty(customers);
     }
 }
Ejemplo n.º 3
0
 public void AddTest()
 {
     var clientRepo = new RepositoryFactory<IClientRepository>().ResolveRepository();
     var count = clientRepo.All().Count();
      clientRepo.Add(new Client{Name="UNITTEST",Description = "UNITTEST"});
     clientRepo.UnitOfWork.Commit();
      Assert.IsTrue(count + 1 == new RepositoryFactory<IClientRepository>().ResolveRepository().All().Count());
 }
Ejemplo n.º 4
0
        public void Can_Use_UoW_To_Remove_And_Add_Customer_In_A_Transaction()
        {
            using (var uow = new MegaEntityFrameworkUnitOfWorkFactory().Create())
            {
                var repo = new RepositoryFactory().Create(uow);
                var c1   = repo.All <Customer>().Single(c => c.Email == "*****@*****.**");
                repo.Delete(c1);
                var c2 = GetCustomer();
                repo.Add(c2);
                uow.Commit();
            }

            using (var repo = new RepositoryFactory().Create())
            {
                var x = repo.All <Customer>().SingleOrDefault(c => c.Email == "*****@*****.**");
                Assert.IsNull(x);
                var y = repo.All <Customer>().Any(c => c.Country == "Italy");
                Assert.IsTrue(y);
            }
        }
Ejemplo n.º 5
0
        public void Can_Save_New_Customer_With_Orders_And_Details()
        {
            var customer = GetCustomer();

            using (var repo = new RepositoryFactory().Create())
            {
                repo.Add(customer);
                repo.Save();
            }

            using (var repo = new RepositoryFactory().Create())
            {
                var cust = repo.All <Customer>().SingleOrDefault(c => c.Email == "*****@*****.**");
                Assert.IsNotNull(cust);
                CollectionAssert.IsNotEmpty(cust.Orders);
                Assert.IsNotNull(cust.Orders.First(o => o.OrderDetail != null).OrderDetail);
            }
        }
Ejemplo n.º 6
0
        public void Can_Save_New_Customer_With_Orders_And_Details()
        {
            var customer = GetCustomer();

            using (var repo = new RepositoryFactory().Create())
            {
                repo.Add(customer);
                repo.Save();
            }

            using (var repo = new RepositoryFactory().Create())
            {
                var cust = repo.All<Customer>().SingleOrDefault(c => c.Email == "*****@*****.**");
                Assert.IsNotNull(cust);
                CollectionAssert.IsNotEmpty(cust.Orders);
                Assert.IsNotNull(cust.Orders.First(o => o.OrderDetail != null).OrderDetail);
            }
        }
Ejemplo n.º 7
0
        public void Can_Save_New_Customer()
        {
            var customer = new Customer
            {
                ContactName = "johnny",
                Email       = "*****@*****.**"
            };

            using (var repo = new RepositoryFactory().Create())
            {
                repo.Add(customer);
                repo.Save();
            }

            using (var repo = new RepositoryFactory().Create())
            {
                var cust = repo.All <Customer>().SingleOrDefault(c => c.Email == "*****@*****.**");
                Assert.IsNotNull(cust);
            }
        }
Ejemplo n.º 8
0
        public void Can_Use_UoW_To_Remove_And_Add_Customer_In_A_Transaction()
        {
            using (var uow = new MegaEntityFrameworkUnitOfWorkFactory().Create())
            {
                var repo = new RepositoryFactory().Create(uow);
                var c1 = repo.All<Customer>().Single(c => c.Email == "*****@*****.**");
                repo.Delete(c1);
                var c2 = GetCustomer();
                repo.Add(c2);
                uow.Commit();
            }

            using (var repo = new RepositoryFactory().Create())
            {
                var x = repo.All<Customer>().SingleOrDefault(c => c.Email == "*****@*****.**");
                Assert.IsNull(x);
                var y = repo.All<Customer>().Any(c => c.Country == "Italy");
                Assert.IsTrue(y);
            }
        }
Ejemplo n.º 9
0
        public void Can_Save_New_Customer()
        {
            var customer = new Customer
            {
                ContactName = "johnny",
                Email = "*****@*****.**"
            };

            using (var repo = new RepositoryFactory().Create())
            {
                repo.Add(customer);
                repo.Save();
            }

            using (var repo = new RepositoryFactory().Create())
            {
                var cust = repo.All<Customer>().SingleOrDefault(c => c.Email == "*****@*****.**");
                Assert.IsNotNull(cust);
            }
        }
Ejemplo n.º 10
0
 public void GetAllTest()
 {
     var productRepo = new RepositoryFactory<IProductRepository>().ResolveRepository();
     var allProducts = productRepo.All();
     Assert.IsNotNull(allProducts.FirstOrDefault());
 }
Ejemplo n.º 11
0
 public void GetAllTest()
 {
     var clientRepo = new RepositoryFactory<IClientRepository>().ResolveRepository();
     var allClients = clientRepo.All();
     Assert.IsTrue(allClients.Count()>0);
 }