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; } }
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; } }
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; } }
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; } }
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; } }
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; } }
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; } }
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"); } }
public void Create() { using (var db = new CustomerContext(dbConnStr)) { var address = new Address(); // AddressFactory.Create(Address.CountryCode.US); address.Country = Address.CountryCode.US; address.Line1 = "Line 1A"; address.Line2 = "Line 2A"; address.State = "NY"; address.ZipCode = "99999"; address.Note = "Note"; address.City = "New York"; address.AddressType = Address.TypeEnum.BillTo; db.Save(address); db.SaveChanges(); Assert.AreEqual(db.Addresses.Count(), 2, "Did not add address"); var add=db.Addresses.FirstOrDefault(a=>a.Id==address.Id); Assert.IsTrue(add.Line1 == "Line 1A" && add.Line2 == "Line 2A" && add.City == "New York" && add.State == "NY" && add.ZipCode == "99999" && add.Note == "Note" && add.AddressType == Address.TypeEnum.BillTo, "Did not save all fields"); } }
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(); } }
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", MiddleName="MiddleName", LastName = "Last", Email = "*****@*****.**",Balance=12.00M}; db.Save(cust); db.SaveChanges(); custId = cust.Id; } }
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 address = new Address(); // AddressFactory.Create(Address.CountryCode.US); address.Country=Address.CountryCode.US; address.Line1 = "Line 1"; address.Line2 = "Line 2"; address.State = "NY"; address.ZipCode = "99999"; address.Note = "Note"; address.City="New York"; address.AddressType = Address.TypeEnum.BillTo; db.Save(address); db.SaveChanges(); id = address.Id; } }