Exemplo n.º 1
0
        public void UpdateCustomerChangeValues()
        {
            using (var bc = new BusinessContext())
            {
                var customer = new Customer
                {
                    Email     = "*****@*****.**",
                    FirstName = "Klaudia",
                    LastName  = "Pałkowska"
                };

                bc.AddNewCustomer(customer);

                const string newEmail     = "*****@*****.**",
                             newFirstName = "Ola",
                             newLastName  = "Fajna";

                customer.Email     = newEmail;
                customer.FirstName = newFirstName;
                customer.LastName  = newLastName;

                bc.UpdateCustomer(customer);

                bc.DataContext.Entry(customer).Reload();

                Assert.AreEqual(newEmail, customer.Email);
                Assert.AreEqual(newFirstName, customer.FirstName);
                Assert.AreEqual(newLastName, customer.LastName);
            }
        }
Exemplo n.º 2
0
        public void GetCustomerListReturnExpectedCustomers()
        {
            using (var bc = new BusinessContext())
            {
                bc.AddNewCustomer(new Customer {
                    Email = "*****@*****.**", FirstName = "1", LastName = "a"
                });
                bc.AddNewCustomer(new Customer {
                    Email = "*****@*****.**", FirstName = "2", LastName = "b"
                });
                bc.AddNewCustomer(new Customer {
                    Email = "*****@*****.**", FirstName = "3", LastName = "c"
                });

                var customers = bc.GetCustomerList();

                Assert.IsTrue(customers.ElementAt(0).Id == 6);
                Assert.IsTrue(customers.ElementAt(1).Id == 7);
                Assert.IsTrue(customers.ElementAt(2).Id == 8);
            }
        }
Exemplo n.º 3
0
        public void AddNewCustomer_ThrowsException_WhenLastNameIsEmpty()
        {
            using (var bc = new BusinessContext())
            {
                var customer = new Customer
                {
                    Email     = "*****@*****.**",
                    FirstName = "David",
                    LastName  = ""
                };

                bc.AddNewCustomer(customer);
            }
        }
Exemplo n.º 4
0
        public void AddNewCustomer_ThrowsException_WhenFirstNameIsEmpty()
        {
            using (var bc = new BusinessContext())
            {
                var customer = new Customer
                {
                    Email     = "*****@*****.**",
                    FirstName = "",
                    LastName  = "Pałkowska"
                };

                bc.AddNewCustomer(customer);
            }
        }
Exemplo n.º 5
0
        public void AddNewCustomer_ThrowsException_WhenFirstNameIsNull()
        {
            using (var bc = new BusinessContext())
            {
                var customer = new Customer
                {
                    Email     = "*****@*****.**",
                    FirstName = null,
                    LastName  = "Anderson"
                };

                bc.AddNewCustomer(customer);
            }
        }
Exemplo n.º 6
0
        public void AddNewCustomer_ThrowsException_WhenEmailNameIsEmpty()
        {
            using (var bc = new BusinessContext())
            {
                var customer = new Customer
                {
                    Email     = "",
                    FirstName = "David",
                    LastName  = "Anderson"
                };

                bc.AddNewCustomer(customer);
            }
        }
Exemplo n.º 7
0
        public void AddNewCustomer_ThrowsExpection_WhenLastNameIsNull()
        {
            using (BusinessContext bc = new BusinessContext())
            {
                var customer = new Customer
                {
                    Email     = "*****@*****.**",
                    FirstName = "David",
                    LastName  = null
                };

                bc.AddNewCustomer(customer);
            }
        }
Exemplo n.º 8
0
        public void AddNewCustomer_ThrowsExpection_WhenEmailIsNull()
        {
            using (BusinessContext bc = new BusinessContext())
            {
                var customer = new Customer
                {
                    Email     = null,
                    FirstName = "David",
                    LastName  = "Anderson"
                };

                bc.AddNewCustomer(customer);
            }
        }
Exemplo n.º 9
0
        public void AddNewCustomerIsSuccessfull()
        {
            using (var bc = new BusinessContext())
            {
                var customer = new Customer
                {
                    Email     = "*****@*****.**",
                    FirstName = "Klaudia",
                    LastName  = "Pałkowska"
                };

                bc.AddNewCustomer(customer);

                bool exists = bc.DataContext.Customers.Any(c => c.Id == customer.Id);
                Assert.IsTrue(exists);
            }
        }
Exemplo n.º 10
0
        public void AddNewCustomerIsPersisted()//Persistence refer to the characteristic of state that outlive the process that created it.
        {
            //using (var dc = new DomainContext()) ;
            using (var bc = new BusinessContext())
            {
                // Customer entity = bc.AddNewCustomer("Van", "Le");
                //Assert.IsNotNull(entity);
                var customer = new Customer()
                {
                    Email     = "*****@*****.**",
                    FirstName = "Van",
                    LastName  = "Le"
                };
                bc.AddNewCustomer(customer);

                bool exists = bc.DataContext.Customers.Any(c => c.Id == customer.Id);
                Assert.IsTrue(exists);
            }
        }
Exemplo n.º 11
0
        public void AddNewCustomerIsPersisted()
        {
            //using (var dc = new DomainContext())
            using (var bc = new BusinessContext())
            {
                //Customer entity = bc.AddNewCustomer("David", "Anderson");
                var customer = new Customer
                {
                    Email     = "*****@*****.**",
                    FirstName = "David",
                    LastName  = "Anderson"
                };

                bc.AddNewCustomer(customer);

                bool exists = bc.DataContext.Customers.Any(c => c.Id == customer.Id);

                Assert.IsTrue(exists);
            }
        }