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 TestSubscription_CanContainCreateAddOns() { subscription subscription = new subscription(); subscription.planCode = "123abc"; createAddOn cao1 = new createAddOn(); cao1.addOnCode = "1"; cao1.name = "addOn1"; cao1.amount = 100; cao1.startDate = new DateTime(2013, 9, 5); cao1.endDate = new DateTime(2013, 9, 6); createAddOn cao2 = new createAddOn(); cao2.addOnCode = "2"; cao2.name = "addOn2"; cao2.amount = 200; cao2.startDate = new DateTime(2013, 9, 4); cao2.endDate = new DateTime(2013, 9, 5); subscription.createAddOns.Add(cao1); subscription.createAddOns.Add(cao2); String actual = subscription.Serialize(); String expected = @" <planCode>123abc</planCode> <createAddOn> <addOnCode>1</addOnCode> <name>addOn1</name> <amount>100</amount> <startDate>2013-09-05</startDate> <endDate>2013-09-06</endDate> </createAddOn> <createAddOn> <addOnCode>2</addOnCode> <name>addOn2</name> <amount>200</amount> <startDate>2013-09-04</startDate> <endDate>2013-09-05</endDate> </createAddOn>"; Assert.AreEqual(expected, actual); }