コード例 #1
0
 public void Read()
 {
     using (var db=new CustomerContext(dbConnStr)) {
         var address = db.Addresses.FirstOrDefault(p => p.Id == id);
         Assert.IsTrue(address.Line1 == "Line 1", "Wrong address");
     }
 }
コード例 #2
0
 public void Teardown()
 {
     using (var dbCtx = new CustomerContext(dbConnStr))
     {
         if (!dbCtx.Database.Delete())
             throw new Exception("Could not delete temporary test db with connection string: " + dbConnStr);
     }
 }
コード例 #3
0
 public void InvoiceType()
 {
     using (var db = new CustomerContext(dbConnStr))
     {
         var invoice = db.Invoices.FirstOrDefault(p => p.Id == invId);
         Assert.IsTrue(invoice.InvoiceType==Invoice.Type.Invoice, "Wrong Type");
     }
 }
コード例 #4
0
 public void Create_Read()
 {
     using (var db = new CustomerContext(dbConnStr))
     {
         var invoice = db.Invoices.FirstOrDefault(p=>p.Id==invId);
         Assert.IsTrue(invoice.Id == invId, "Wrong invoice");
     }
 }
コード例 #5
0
        public void Create_Read()
        {
            using (var db = new CustomerContext(dbConnStr))
            {
                var item = db.ItemPricings.FirstOrDefault(p => p.Id == id);
                Assert.IsTrue(item.OverrideGlacctno == "abcd" && item.PromoCode == "code" && item.UnitPrice == 30M, "Incorrect item pricing");

            }
        }
コード例 #6
0
        public void Create_Read()
        {
            using (var db = new CustomerContext(dbConnStr))
            {
                var phone = db.Phones.FirstOrDefault(p => p.Id == id);
                Assert.IsTrue(phone.Number == "123-456-7899" && phone.PhoneType ==Phone.Type.Work && phone.CountryCallingCode == "Code", "Incorrect phone info");

            }
        }
コード例 #7
0
        public void Create_Read()
        {
            using (var db = new CustomerContext(dbConnStr))
            {
                var paymenttype = db.PaymentTypes.FirstOrDefault(p => p.Id == id);
                Assert.IsTrue(paymenttype.Source == "creditcard" && paymenttype.SourceId==1, "Incorrect paymenttype info");

            }
        }
コード例 #8
0
        public void Create_Read()
        {
            using (var db = new CustomerContext(dbConnStr))
            {
                var payment = db.Payments.FirstOrDefault(p => p.Id == id);
                Assert.IsTrue(payment.Amount ==300M && payment.Response == "response" && payment.StatusCode == "code", "Incorrect payment info");

            }
        }
コード例 #9
0
 public void Create_Read()
 {
     using (var db = new CustomerContext(dbConnStr))
     {
         var item = db.Items.First(p => p.Id == itemId);
         Assert.AreEqual(item.Id, itemId, "Not reading correct item");
         Assert.IsTrue(item.SubscriptionDays == 30, "wrong item");
         Assert.IsTrue(item.Glacctno == "1234", "wrong item");
     }
 }
コード例 #10
0
        public void TestModifyBalance()
        {
            cs.ModifyBalance(custId, 5M);

            using (var db = new CustomerContext(dbConnStr))
            {
                var cust = db.Customers.First(p => p.Id == custId);
                Assert.AreEqual(cust.Balance, 17M, "Balance is not updated");
                Assert.IsTrue(cust.FirstName == "First", "wrong name");
            }
        }
コード例 #11
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");
     }
 }
コード例 #12
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");
        }
 }
コード例 #13
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");
     }
 }
コード例 #14
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");
     }
 }
コード例 #15
0
        public void Setup()
        {
            dbConnStr = buildConnectionString(CustomerManagementTest.Properties.Settings.Default.TestDb, () => DateTimeOffset.UtcNow.ToString("yyyy-MM-dd_hh:mm:ssZ"));

            using (var db = new CustomerContext(dbConnStr))
            {
                var payment = new Payment {Amount=300M, Response="response", StatusCode="code" };
                db.Save(payment);
                db.SaveChanges();
                id = payment.Id;
            }
        }
コード例 #16
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);

            }
        }
コード例 #17
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");
     }
 }
コード例 #18
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");

            }
        }
コード例 #19
0
        public void TestSetup()
        {
            dbConnStr = buildConnectionString(CustomerManagementTest.Properties.Settings.Default.TestDb, () => DateTimeOffset.UtcNow.ToString("yyyy-MM-dd_hh:mm:ssZ"));

            using (var db = new CustomerContext(dbConnStr))
            {
                var invoicedetail = new InvoiceDetail { ItemUnits=10 };
                db.Save(invoicedetail);
                db.SaveChanges();
                invId = invoicedetail.Id;
            }
        }
コード例 #20
0
        public void Setup()
        {
            dbConnStr = buildConnectionString(CustomerManagementTest.Properties.Settings.Default.TestDb, () => DateTimeOffset.UtcNow.ToString("yyyy-MM-dd_hh:mm:ssZ"));

            using (var db = new CustomerContext(dbConnStr))
            {
                var paymenttype = new PaymentType {Source="creditcard", SourceId=1};
                db.Save(paymenttype);
                db.SaveChanges();
                id = paymenttype.Id;
            }
        }
コード例 #21
0
        public void Setup()
        {
            dbConnStr = buildConnectionString(CustomerManagementTest.Properties.Settings.Default.TestDb, () => DateTimeOffset.UtcNow.ToString("yyyy-MM-dd_hh:mm:ssZ"));

            using (var db = new CustomerContext(dbConnStr))
            {
                var phone = new Phone {Number="123-456-7899", PhoneType=Phone.Type.Work, CountryCallingCode="Code"  };
                db.Save(phone);
                db.SaveChanges();
                id = phone.Id;
            }
        }
コード例 #22
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");
     }
 }
コード例 #23
0
        public void TestSetup()
        {
            dbConnStr = buildConnectionString(CustomerManagementTest.Properties.Settings.Default.TestDb, () => DateTimeOffset.UtcNow.ToString("yyyy-MM-dd_hh:mm:ssZ"));

            using (var db = new CustomerContext(dbConnStr))
            {
                var item = new Item { ItemClass = "iclass", SubscriptionDays = 30, Glacctno = "1234" };
                db.Save(item);
                db.SaveChanges();
                itemId = item.Id;

            }
        }
コード例 #24
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");
     }
 }
コード例 #25
0
        public void TestCreate()
        {
            using (var db = new CustomerContext(dbConnStr))
            {
                var cust = new Customer { CustomerType = "type", UserId = 2, FirstName = "First", LastName = "Last", Email = "*****@*****.**",Balance=12.00M};
                db.Save(cust);
                db.SaveChanges();
                var count = db.Customers.Count();
                var newcust = db.Customers.First(p => p.Id == cust.Id);
                Assert.IsTrue(count == 2, "Incorrect count");
                Assert.IsTrue(newcust.UserId == 2 && cust.Id == newcust.Id, "Customer does not match");

            }
        }
コード例 #26
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");

            }
        }
コード例 #27
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");
     }
 }
コード例 #28
0
        public void Setup()
        {
            dbConnStr = buildConnectionString(CustomerManagementTest.Properties.Settings.Default.TestDb, () => DateTimeOffset.UtcNow.ToString("yyyy-MM-dd_hh:mm:ssZ"));

            using (var db = new CustomerContext(dbConnStr))
            {
                var item = new Item { ItemClass = "iclass", SubscriptionDays = 30, Glacctno = "1234" };

                var itempricing = new ItemPricing { Item = item, OverrideGlacctno = "abcd", PromoCode = "code", UnitPrice = 30M, StartDate = DateTime.UtcNow.AddHours(-1), EndDate = DateTime.UtcNow.AddHours(300) };
                db.Save(itempricing);
                db.SaveChanges();
                id = itempricing.Id;
            }
        }
コード例 #29
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");
     }
 }
コード例 #30
0
        public void TestSetup()
        {
            dbConnStr = buildConnectionString(CustomerManagementTest.Properties.Settings.Default.TestDb, () => DateTimeOffset.UtcNow.ToString("yyyy-MM-dd_hh:mm:ssZ"));

            using (var db = new CustomerContext(dbConnStr))
            {
                var customer = new Customer { CustomerType = "type", UserId = 1, FirstName = "First", LastName = "Last", Email = "*****@*****.**" };
                db.Save(customer);
                db.SaveChanges();
                var invoice = new Invoice { Customer = customer, InvoiceType = Invoice.Type.Invoice, Note="Note", PaymentNote="Payment Note" } ;
                db.Save(invoice);
                db.SaveChanges();
                invId = invoice.Id;

            }
        }