Ejemplo n.º 1
0
 public void Delete()
 {
     using (var db = new CustomerContext(dbConnStr))
     {
         var phone = db.Phones.FirstOrDefault(p => p.Id == id);
         db.Attach(phone);
         phone.IsDeleted = true;
         db.SaveChanges();
         Assert.IsTrue(db.Phones.Where(p => !p.IsDeleted).Count() == 0, "Not deleted");
     }
 }
Ejemplo n.º 2
0
 public void Delete()
 {
     using (var db = new CustomerContext(dbConnStr))
     {
         var itempricing = db.ItemPricings.FirstOrDefault(p => p.Id == id);
         db.Attach(itempricing);
         itempricing.IsDeleted = true;
         db.SaveChanges();
         Assert.IsTrue(db.ItemPricings.Where(p=>!p.IsDeleted).Count()==0, "Not deleted");
     }
 }
Ejemplo n.º 3
0
 public void Delete()
 {
     using (var db = new CustomerContext(dbConnStr))
     {
         var item = db.Items.First(p => p.Id == itemId);
         db.Attach(item);
         item.IsDeleted = true;
         db.SaveChanges();
         Assert.IsTrue(db.Items.Where(p => !p.IsDeleted).Count() == 0, "Did not delete");
        }
 }
Ejemplo n.º 4
0
 public void TestDelete()
 {
     using (var db = new CustomerContext(dbConnStr))
     {
         var cust = db.Customers.First(p => p.Id == custId);
         db.Attach(cust);
         cust.IsDeleted = true;
         db.SaveChanges();
         cust = db.Customers.First(p => p.Id == custId);
         Assert.IsTrue(cust.IsDeleted == true, "Is not set to delete");
     }
 }
Ejemplo n.º 5
0
        public void Delete()
        {
            using (var db = new CustomerContext(dbConnStr))
            {
                var invoice = db.Invoices.FirstOrDefault(p => p.Id == invId);
                db.Attach(invoice);
                invoice.IsDeleted = true;
                db.SaveChanges();
                Assert.AreEqual(db.Invoices.Where(i => !i.IsDeleted).Count(), 0, "No deletes");

            }
        }
Ejemplo n.º 6
0
        public void Delete()
        {
            using (var db = new CustomerContext(dbConnStr))
            {
                var address = db.Addresses.FirstOrDefault(p => p.Id == id);
                db.Attach(address);
                address.IsDeleted = true;
                db.SaveChanges();
                Assert.AreEqual(db.Addresses.Where(a => !a.IsDeleted).Count(), 0);

            }
        }
 public void Update()
 {
     using (var db = new CustomerContext(dbConnStr))
     {
         var invoicedetail = db.InvoiceDetails.FirstOrDefault(p => p.Id == invId);
         db.Attach(invoicedetail);
         invoicedetail.ItemUnits = 12;
         db.SaveChanges();
         var upinvoicedetail = db.InvoiceDetails.FirstOrDefault();
         Assert.IsTrue(upinvoicedetail.ItemUnits == 12, "Wrong invoicedetail");
     }
 }
Ejemplo n.º 8
0
 public void Update()
 {
     using (var db = new CustomerContext(dbConnStr))
     {
         var paymenttype = db.PaymentTypes.FirstOrDefault(p => p.Id == id);
         db.Attach(paymenttype);
         paymenttype.Source = "credit card update";
         paymenttype.SourceId = 2;
         db.SaveChanges();
         paymenttype = db.PaymentTypes.FirstOrDefault(p => p.Id == id);
         Assert.IsTrue(paymenttype.Source == "credit card update" && paymenttype.SourceId == 2, "Incorrect paymenttype info");
     }
 }
Ejemplo n.º 9
0
 public void Update()
 {
     using (var db = new CustomerContext(dbConnStr))
     {
         var phone = db.Phones.FirstOrDefault(p => p.Id == id);
         db.Attach(phone);
         phone.Number= "9987654321";
         phone.PhoneType = Phone.Type.Cell;
         phone.CountryCallingCode = "Code update";
         db.SaveChanges();
         phone = db.Phones.FirstOrDefault(p => p.Id == id);
         Assert.IsTrue(phone.Number == "9987654321" && phone.PhoneType == Phone.Type.Cell && phone.CountryCallingCode == "Code update", "Incorrect update");
     }
 }
Ejemplo n.º 10
0
 public void Update()
 {
     using (var db = new CustomerContext(dbConnStr))
     {
         var itempricing = db.ItemPricings.FirstOrDefault(p => p.Id == id);
         db.Attach(itempricing);
         itempricing.OverrideGlacctno = "abcd update";
         itempricing.PromoCode = "code update";
         itempricing.UnitPrice = 70M;
         db.SaveChanges();
         itempricing = db.ItemPricings.FirstOrDefault(p => p.Id == id);
         Assert.IsTrue(itempricing.OverrideGlacctno == "abcd update" && itempricing.PromoCode == "code update" && itempricing.UnitPrice == 70M, "Incorrect item pricing");
     }
 }
Ejemplo n.º 11
0
        public void TestItemPricing()
        {
            using (var db = new CustomerContext(dbConnStr))
            {
                var item = db.Items.First(p => p.Id == itemId);
                db.Attach(item);
                var itempricing = new ItemPricing { Item=item, OverrideGlacctno="abcd", PromoCode="code", UnitPrice=30M, StartDate=DateTime.UtcNow.AddHours(-1), EndDate=DateTime.UtcNow.AddHours(300)   };
                item.ItemPricings.Add(itempricing);
                db.SaveChanges();
                item = db.Items.First(p => p.Id == itemId);
                Assert.IsTrue(item.ItemPricings.Count == 1, "Did not save Item pricing");

            }
        }
Ejemplo n.º 12
0
 public void Update()
 {
     using (var db = new CustomerContext(dbConnStr))
     {
         var payment = db.Payments.FirstOrDefault(p => p.Id == id);
         db.Attach(payment);
         payment.Amount= 700M;
         payment.Response = "response update";
         payment.StatusCode = "Code update";
         db.SaveChanges();
         payment = db.Payments.FirstOrDefault(p => p.Id == id);
         Assert.IsTrue(payment.Amount == 700M && payment.Response == "response update" && payment.StatusCode == "Code update", "Incorrect payment info");
     }
 }
Ejemplo n.º 13
0
        public void Update_WithDifferentCountry()
        {
            using (var db = new CustomerContext(dbConnStr))
            {
                var address = db.Addresses.FirstOrDefault(p => p.Id == id);
                db.Attach(address);
                address.Country = Address.CountryCode.UK;

                address.State = "BNE";
                db.SaveChanges();

                var add = db.Addresses.FirstOrDefault(p => p.Id == id);

                Assert.IsTrue(add.Country == Address.CountryCode.UK, "Country did not change");
                address = db.Addresses.FirstOrDefault(p => p.Id == id);
                address.State = "BNE";
                db.SaveChanges();

            }
        }
Ejemplo n.º 14
0
        public void Update()
        {
            using (var db = new CustomerContext(dbConnStr))
            {
                var invoice = db.Invoices.FirstOrDefault(p => p.Id == invId);
                db.Attach(invoice);
                invoice.Note = "Note Update";
                invoice.PaymentNote = "Payment Note Update";
                db.SaveChanges();
                var upinvoice = db.Invoices.FirstOrDefault();
                Assert.IsTrue(upinvoice.Note == "Note Update", "Wrong invoice");
                Assert.IsTrue(upinvoice.PaymentNote == "Payment Note Update", "Wrong invoice");

            }
        }
Ejemplo n.º 15
0
 public void TestUpdate()
 {
     using (var db = new CustomerContext(dbConnStr))
     {
         var cust = db.Customers.First(p => p.Id == custId);
         db.Attach(cust);
         cust.FirstName = "New Name";
         cust.LastName = "New Name";
         cust.MiddleName = "New Name";
         cust.CustomerType = "New Type";
         db.SaveChanges();
         cust = db.Customers.First(p => p.Id == custId);
         Assert.IsTrue(cust.FirstName == "New Name", "no change");
         Assert.IsTrue(cust.LastName == "New Name", "no change");
         Assert.IsTrue(cust.MiddleName == "New Name", "no change");
         Assert.IsTrue(cust.CustomerType == "New Type", "no change");
     }
 }
        public void TestSetup()
        {
            dbConnStr = buildConnectionString(CustomerManagementTest.Properties.Settings.Default.TestDb, () => DateTimeOffset.UtcNow.ToString("yyyy-MM-dd_hh:mm:ssZ"));

            var csMock = new Mock<CustomerManager>();
            csMock.CallBase = true;
            csMock.Protected().SetupGet<Func<CustomerContext>>("Db").Returns(() => new CustomerContext(dbConnStr));
            cs = csMock.Object;

            using (var db = new CustomerContext(dbConnStr))
            {
                var cust = new Customer { CustomerType = "type", UserId = 1, FirstName = "First", LastName = "Last", Email = "*****@*****.**", Balance = 12.00M };

                db.Save(cust);
                db.SaveChanges();
                Id = cust.Id;
                db.Attach(cust);

                var addr = new Address(); //AddressFactory.Create(Address.CountryCode.US);
                addr.Country = Address.CountryCode.US;
                addr.AddressType = Address.TypeEnum.BillTo;
                addr.Line1 = "Line1";
                addr.Line2 = "Line2";
                addr.State = "NY";
                addr.ZipCode = "99999";
                cust.Addresses.Add(addr);
                db.SaveChanges();
                addrId = addr.Id;

                var phone = new Phone();
                phone.CountryCallingCode = "Code";
                phone.Number = "123-123-1234";
                phone.PhoneType = Phone.Type.Work;

                cust.Phones.Add(phone);
                db.SaveChanges();
                phoneId = phone.Id;

                customer = cust;

                items = new List<Item>
                {
                    new Item {Glacctno="1234", ItemClass="iclass", SubscriptionDays=30, ItemPricings=new List<ItemPricing> {new ItemPricing {Description="describe 1", OverrideGlacctno="og1234", PromoCode="promo code", StartDate=DateTime.Now.AddHours(-1), EndDate=DateTime.Now.AddHours(5), UnitPrice=10.00M},new ItemPricing {Description="describe 1b", OverrideGlacctno="og1234B", PromoCode="promo codeB", StartDate=DateTime.Now.AddHours(-1), EndDate=DateTime.Now.AddHours(5), UnitPrice=52.00M} }},
                    new Item {Glacctno="12345", ItemClass="iclass", SubscriptionDays=31, ItemPricings=new List<ItemPricing> {new ItemPricing {Description="describe 2", OverrideGlacctno="og12345", PromoCode="promo code2", StartDate=DateTime.Now.AddHours(-1), EndDate=DateTime.Now.AddHours(5), UnitPrice=11.00M} }},
                    new Item {Glacctno="123456", ItemClass="iclass", SubscriptionDays=32, ItemPricings=new List<ItemPricing> {new ItemPricing {Description="describe 3", OverrideGlacctno="og123456", PromoCode="promo code3", StartDate=DateTime.Now.AddHours(-1), EndDate=DateTime.Now.AddHours(5), UnitPrice=12.00M} }}
                };

                foreach (var i in items)
                {

                    db.Save(i);

                }
                db.SaveChanges();

            }
        }
Ejemplo n.º 17
0
 public void Update()
 {
     using (var db = new CustomerContext(dbConnStr))
     {
         var item = db.Items.First(p => p.Id == itemId);
         db.Attach(item);
         item.ItemClass = "iclass update";
         item.SubscriptionDays = 40;
         item.Glacctno = "1234 update";
         db.SaveChanges();
         db.Items.First(p => p.Id == itemId);
         Assert.IsTrue(item.ItemClass == "iclass update" && item.SubscriptionDays == 40 && item.Glacctno == "1234 update", "Did nto update");
     }
 }
Ejemplo n.º 18
0
        public void Update()
        {
            using (var db = new CustomerContext(dbConnStr))
            {
                var address = db.Addresses.FirstOrDefault(p => p.Id == id);
                db.Attach(address);
                address.Line1 = "Update Line 1A";
                address.Line2 = "Update Line 2A";
                address.City = "Los Angeles";
                address.State = "CA";
                address.ZipCode = "90000";
                address.Note = "Note Update";

                address.AddressType = Address.TypeEnum.ShipTo;

                db.SaveChanges();
                var add=db.Addresses.FirstOrDefault(p => p.Id == id);
                Assert.IsTrue(add.Line1 == "Update Line 1A" && add.Line2 == "Update Line 2A" && add.City == "Los Angeles" && add.State == "CA" && add.ZipCode == "90000" && add.Note == "Note Update" && add.AddressType == Address.TypeEnum.ShipTo, "Did not update");

            }
        }