Exemple #1
0
        public void AttachNewTest()
        {
            var cust = new Customer()
            {
                Company   = "East Wind Technologies",
                FirstName = "Jimmy",
                LastName  = "Ropain",
            };

            using (var custBus = new busCustomer())
            {
                custBus.Attach(cust, true);
                Assert.IsTrue(custBus.Save(), custBus.ErrorMessage);
            }

            int custId = cust.Id;

            // load new bus/context to force load from disk
            // otherwise load loads from cached context
            using (var custBus = new busCustomer())
            {
                Customer cust2 = custBus.Load(custId);
                Assert.IsNotNull(cust2, custBus.ErrorMessage);

                Assert.AreEqual(cust.Company, cust2.Company);

                Assert.IsTrue(custBus.Delete(custId), custBus.ErrorMessage);
            }

            Console.WriteLine(custId);
        }
Exemple #2
0
        public void AttachExistingTest()
        {
            string newCompany = "West Wind " + DateTime.Now;
            int    custId     = 1;

            var cust = new Customer()
            {
                Id        = custId,
                Company   = newCompany,
                FirstName = "Ricky",
                LastName  = "Strahl",
                Address   = "33 Kaiea Place"
            };

            using (var custBo = new busCustomer())
            {
                custBo.Attach(cust);
                Assert.IsTrue(custBo.Save(), custBo.ErrorMessage);
            }

            // load new bus/context to force load from disk
            // otherwise load loads from cached context
            using (var custBus = new busCustomer())
            {
                Customer cust2 = custBus.Load(custId);
                Assert.IsNotNull(cust2, custBus.ErrorMessage);

                Assert.AreEqual(cust2.Company, newCompany);
            }
        }
Exemple #3
0
        public void AttachExistingTest()
        {
            int      custId = 0;
            Customer cust;
            DateTime time = DateTime.Now;


            using (var custBo = new busCustomer())
            {
                // grab existing customer id we can update
                custId = custBo.Context.Customers
                         .Where(c => c.LastName == "Strahl")
                         .Select(c => c.Id)
                         .First();

                cust = new Customer()
                {
                    Id        = custId,
                    FirstName = "Ricky",
                    LastName  = "Strahl",
                    Company   = "West Wind",
                    Entered   = time,
                    Address   = "31 Kaiea Place"
                };

                custBo.Attach(cust);
                Assert.IsTrue(custBo.Save(), custBo.ErrorMessage);
            }

            using (var custBo2 = new busCustomer())
            {
                // load new bus/context to force load from disk
                // otherwise load loads from cached context
                Customer cust2 = custBo2.Load(custId);
                Assert.IsNotNull(cust2, custBo2.ErrorMessage);

                Assert.IsTrue(cust2.Entered.ToString() == cust.Entered.ToString());
            }
        }