public void TestSubscription_CanContainCreateDiscounts() { subscription subscription = new subscription(); subscription.planCode = "123abc"; createDiscount cd1 = new createDiscount(); cd1.discountCode = "1"; cd1.name = "cheaper"; cd1.amount = 200; cd1.startDate = new DateTime(2013, 9, 5); cd1.endDate = new DateTime(2013, 9, 6); createDiscount cd2 = new createDiscount(); cd2.discountCode = "2"; cd2.name = "cheap"; cd2.amount = 100; cd2.startDate = new DateTime(2013, 9, 3); cd2.endDate = new DateTime(2013, 9, 4); subscription.createDiscounts.Add(cd1); subscription.createDiscounts.Add(cd2); String actual = subscription.Serialize(); String expected = @" <planCode>123abc</planCode> <createDiscount> <discountCode>1</discountCode> <name>cheaper</name> <amount>200</amount> <startDate>2013-09-05</startDate> <endDate>2013-09-06</endDate> </createDiscount> <createDiscount> <discountCode>2</discountCode> <name>cheap</name> <amount>100</amount> <startDate>2013-09-03</startDate> <endDate>2013-09-04</endDate> </createDiscount>"; Assert.AreEqual(expected, actual); }
public void testUpdateSubscription_CanContainCreateDiscounts() { createDiscount cd1 = new createDiscount(); cd1.discountCode = "1"; cd1.name = "cheaper"; cd1.amount = 200; cd1.startDate = new DateTime(2013,9,5); cd1.endDate = new DateTime(2013,9,6); createDiscount cd2 = new createDiscount(); cd2.discountCode = "2"; cd2.name = "cheap"; cd2.amount = 100; cd2.startDate = new DateTime(2013, 9, 3); cd2.endDate = new DateTime(2013, 9, 4); updateSubscription update = new updateSubscription(); update.subscriptionId = 1; update.createDiscounts.Add(cd1); update.createDiscounts.Add(cd2); String actual = update.Serialize(); String expected = @" <updateSubscription> <subscriptionId>1</subscriptionId> <createDiscount> <discountCode>1</discountCode> <name>cheaper</name> <amount>200</amount> <startDate>2013-09-05</startDate> <endDate>2013-09-06</endDate> </createDiscount> <createDiscount> <discountCode>2</discountCode> <name>cheap</name> <amount>100</amount> <startDate>2013-09-03</startDate> <endDate>2013-09-04</endDate> </createDiscount> </updateSubscription>"; Assert.AreEqual(expected, actual); }
public void TestCreateDiscount_Full() { createDiscount cd = new createDiscount(); cd.discountCode = "1"; cd.name = "cheaper"; cd.amount = 200; cd.startDate = new DateTime(2013, 9, 5); cd.endDate = new DateTime(2013, 9, 6); String actual = cd.Serialize(); String expected = @" <discountCode>1</discountCode> <name>cheaper</name> <amount>200</amount> <startDate>2013-09-05</startDate> <endDate>2013-09-06</endDate>"; Assert.AreEqual(expected, actual); }