Serialize() public méthode

public Serialize ( ) : string
Résultat string
        public void TestUpdateSubscription_Full()
        {
            updateSubscription update = new updateSubscription();

            update.billingDate = new DateTime(2002, 10, 9);
            contact billToAddress = new contact();

            billToAddress.name   = "Greg Dake";
            billToAddress.city   = "Lowell";
            billToAddress.state  = "MA";
            billToAddress.email  = "*****@*****.**";
            update.billToAddress = billToAddress;
            cardType card = new cardType();

            card.number           = "4100000000000001";
            card.expDate          = "1215";
            card.type             = methodOfPaymentTypeEnum.VI;
            update.card           = card;
            update.planCode       = "abcdefg";
            update.subscriptionId = 12345;

            String actual   = update.Serialize();
            String expected = "\r\n<updateSubscription>\r\n<subscriptionId>12345</subscriptionId>\r\n<planCode>abcdefg</planCode>\r\n<billToAddress>\r\n<name>Greg Dake</name>\r\n<city>Lowell</city>\r\n<state>MA</state>\r\n<email>[email protected]</email>\r\n</billToAddress>\r\n<card>\r\n<type>VI</type>\r\n<number>4100000000000001</number>\r\n<expDate>1215</expDate>\r\n</card>\r\n<billingDate>2002-10-09</billingDate>\r\n</updateSubscription>";

            Assert.AreEqual(Regex.Replace(expected, @"\s+", String.Empty), Regex.Replace(actual, @"\s+", String.Empty));
        }
Exemple #2
0
        public void testUpdateSubscription_CanContainDeleteDiscounts()
        {
            var dd1 = new deleteDiscount();

            dd1.discountCode = "1";

            var dd2 = new deleteDiscount();

            dd2.discountCode = "2";

            var update = new updateSubscription();

            update.subscriptionId = 1;
            update.deleteDiscounts.Add(dd1);
            update.deleteDiscounts.Add(dd2);

            var actual   = update.Serialize();
            var expected = @"
<updateSubscription>
<subscriptionId>1</subscriptionId>
<deleteDiscount>
<discountCode>1</discountCode>
</deleteDiscount>
<deleteDiscount>
<discountCode>2</discountCode>
</deleteDiscount>
</updateSubscription>";

            Assert.AreEqual(expected, actual);
        }
Exemple #3
0
        public void TestUpdateSubscription()
        {
            var update = new updateSubscription();

            update.billingDate = new DateTime(2002, 10, 9);
            var billToAddress = new contact();

            billToAddress.name   = "Greg Dake";
            billToAddress.city   = "Lowell";
            billToAddress.state  = "MA";
            billToAddress.email  = "*****@*****.**";
            update.billToAddress = billToAddress;
            var card = new cardType();

            card.number           = "4100000000000001";
            card.expDate          = "1215";
            card.type             = methodOfPaymentTypeEnum.VI;
            update.card           = card;
            update.planCode       = "abcdefg";
            update.subscriptionId = 12345;

            batchRequest.addUpdateSubscription(update);

            Assert.AreEqual(1, batchRequest.getNumUpdateSubscriptions());

            mockCnpFile.Verify(cnpFile => cnpFile.createRandomFile(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), mockCnpTime.Object));
            mockCnpFile.Verify(cnpFile => cnpFile.AppendLineToFile(mockFilePath, update.Serialize()));
        }
        public void testUpdateSubscription_CanContainDeleteAddOns()
        {
            deleteAddOn dao1 = new deleteAddOn();

            dao1.addOnCode = "1";

            deleteAddOn dao2 = new deleteAddOn();

            dao2.addOnCode = "2";

            updateSubscription update = new updateSubscription();

            update.subscriptionId = 1;
            update.deleteAddOns.Add(dao1);
            update.deleteAddOns.Add(dao2);

            String actual   = update.Serialize();
            String expected = @"
<updateSubscription>
<subscriptionId>1</subscriptionId>
<deleteAddOn>
<addOnCode>1</addOnCode>
</deleteAddOn>
<deleteAddOn>
<addOnCode>2</addOnCode>
</deleteAddOn>
</updateSubscription>";

            Assert.AreEqual(Regex.Replace(expected, @"\s+", String.Empty), Regex.Replace(actual, @"\s+", String.Empty));
        }
Exemple #5
0
        public void testUpdateSubscription_CanContainDeleteAddOns()
        {
            var dao1 = new deleteAddOn();

            dao1.addOnCode = "1";

            var dao2 = new deleteAddOn();

            dao2.addOnCode = "2";

            var update = new updateSubscription();

            update.subscriptionId = 1;
            update.deleteAddOns.Add(dao1);
            update.deleteAddOns.Add(dao2);

            var actual   = update.Serialize();
            var expected = @"
<updateSubscription>
<subscriptionId>1</subscriptionId>
<deleteAddOn>
<addOnCode>1</addOnCode>
</deleteAddOn>
<deleteAddOn>
<addOnCode>2</addOnCode>
</deleteAddOn>
</updateSubscription>";

            Assert.AreEqual(expected, actual);
        }
        public void testUpdateSubscription_CanContainDeleteDiscounts()
        {
            deleteDiscount dd1 = new deleteDiscount();

            dd1.discountCode = "1";

            deleteDiscount dd2 = new deleteDiscount();

            dd2.discountCode = "2";

            updateSubscription update = new updateSubscription();

            update.subscriptionId = 1;
            update.deleteDiscounts.Add(dd1);
            update.deleteDiscounts.Add(dd2);

            String actual   = update.Serialize();
            String expected = @"
<updateSubscription>
<subscriptionId>1</subscriptionId>
<deleteDiscount>
<discountCode>1</discountCode>
</deleteDiscount>
<deleteDiscount>
<discountCode>2</discountCode>
</deleteDiscount>
</updateSubscription>";

            Assert.AreEqual(Regex.Replace(expected, @"\s+", String.Empty), Regex.Replace(actual, @"\s+", String.Empty));
        }
Exemple #7
0
        public void testUpdateSubscription_OnlyRequired()
        {
            updateSubscription update = new updateSubscription();

            update.subscriptionId = 12345;

            String actual   = update.Serialize();
            String expected = "\r\n<updateSubscription>\r\n<subscriptionId>12345</subscriptionId>\r\n</updateSubscription>";

            Assert.AreEqual(expected, actual);
        }
        public void testUpdateSubscription_OnlyRequired()
        {
            updateSubscription update = new updateSubscription();

            update.subscriptionId = 12345;

            String actual   = update.Serialize();
            String expected = "\r\n<updateSubscription>\r\n<subscriptionId>12345</subscriptionId>\r\n</updateSubscription>";

            Assert.AreEqual(Regex.Replace(expected, @"\s+", String.Empty), Regex.Replace(actual, @"\s+", String.Empty));
        }
Exemple #9
0
        public void testUpdateSubscription_CanContainCreateAddOns()
        {
            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);

            updateSubscription update = new updateSubscription();

            update.subscriptionId = 1;
            update.createAddOns.Add(cao1);
            update.createAddOns.Add(cao2);

            String actual   = update.Serialize();
            String expected = @"
<updateSubscription>
<subscriptionId>1</subscriptionId>
<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>
</updateSubscription>";

            Assert.AreEqual(expected, actual);
        }
Exemple #10
0
        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 testUpdateSubscription_CanContainUpdateDiscounts()
        {
            updateDiscount ud1 = new updateDiscount();

            ud1.discountCode = "1";
            ud1.name         = "cheaper";
            ud1.amount       = 200;
            ud1.startDate    = new DateTime(2013, 9, 5);
            ud1.endDate      = new DateTime(2013, 9, 6);

            updateDiscount ud2 = new updateDiscount();

            ud2.discountCode = "2";
            ud2.name         = "cheap";
            ud2.amount       = 100;
            ud2.startDate    = new DateTime(2013, 9, 3);
            ud2.endDate      = new DateTime(2013, 9, 4);

            updateSubscription update = new updateSubscription();

            update.subscriptionId = 1;
            update.updateDiscounts.Add(ud1);
            update.updateDiscounts.Add(ud2);

            String actual   = update.Serialize();
            String expected = @"
<updateSubscription>
<subscriptionId>1</subscriptionId>
<updateDiscount>
<discountCode>1</discountCode>
<name>cheaper</name>
<amount>200</amount>
<startDate>2013-09-05</startDate>
<endDate>2013-09-06</endDate>
</updateDiscount>
<updateDiscount>
<discountCode>2</discountCode>
<name>cheap</name>
<amount>100</amount>
<startDate>2013-09-03</startDate>
<endDate>2013-09-04</endDate>
</updateDiscount>
</updateSubscription>";

            Assert.AreEqual(Regex.Replace(expected, @"\s+", String.Empty), Regex.Replace(actual, @"\s+", String.Empty));
        }
        public void testUpdateSubscription_CanContainUpdateAddOns()
        {
            updateAddOn uao1 = new updateAddOn();

            uao1.addOnCode = "1";
            uao1.name      = "addOn1";
            uao1.amount    = 100;
            uao1.startDate = new DateTime(2013, 9, 5);
            uao1.endDate   = new DateTime(2013, 9, 6);

            updateAddOn uao2 = new updateAddOn();

            uao2.addOnCode = "2";
            uao2.name      = "addOn2";
            uao2.amount    = 200;
            uao2.startDate = new DateTime(2013, 9, 4);
            uao2.endDate   = new DateTime(2013, 9, 5);

            updateSubscription update = new updateSubscription();

            update.subscriptionId = 1;
            update.updateAddOns.Add(uao1);
            update.updateAddOns.Add(uao2);

            String actual   = update.Serialize();
            String expected = @"
<updateSubscription>
<subscriptionId>1</subscriptionId>
<updateAddOn>
<addOnCode>1</addOnCode>
<name>addOn1</name>
<amount>100</amount>
<startDate>2013-09-05</startDate>
<endDate>2013-09-06</endDate>
</updateAddOn>
<updateAddOn>
<addOnCode>2</addOnCode>
<name>addOn2</name>
<amount>200</amount>
<startDate>2013-09-04</startDate>
<endDate>2013-09-05</endDate>
</updateAddOn>
</updateSubscription>";

            Assert.AreEqual(Regex.Replace(expected, @"\s+", String.Empty), Regex.Replace(actual, @"\s+", String.Empty));
        }
        public void testUpdateSubscription_CanContainPaypage()
        {
            updateSubscription update = new updateSubscription();

            update.subscriptionId = 1;
            update.paypage        = new cardPaypageType();
            update.paypage.paypageRegistrationId = "abc123";

            String actual   = update.Serialize();
            String expected = @"
<updateSubscription>
<subscriptionId>1</subscriptionId>
<paypage>
<paypageRegistrationId>abc123</paypageRegistrationId>
</paypage>
</updateSubscription>";

            Assert.AreEqual(Regex.Replace(expected, @"\s+", String.Empty), Regex.Replace(actual, @"\s+", String.Empty));
        }
        public void testUpdateSubscription_CanContainToken()
        {
            updateSubscription update = new updateSubscription();

            update.subscriptionId   = 1;
            update.token            = new cardTokenType();
            update.token.litleToken = "123456";

            String actual   = update.Serialize();
            String expected = @"
<updateSubscription>
<subscriptionId>1</subscriptionId>
<token>
<litleToken>123456</litleToken>
</token>
</updateSubscription>";

            Assert.AreEqual(Regex.Replace(expected, @"\s+", String.Empty), Regex.Replace(actual, @"\s+", String.Empty));
        }
Exemple #15
0
        public void testUpdateSubscription_CanContainToken()
        {
            var update = new updateSubscription();

            update.subscriptionId   = 1;
            update.token            = new cardTokenType();
            update.token.litleToken = "123456";

            var actual   = update.Serialize();
            var expected = @"
<updateSubscription>
<subscriptionId>1</subscriptionId>
<token>
<litleToken>123456</litleToken>
</token>
</updateSubscription>";

            Assert.AreEqual(expected, actual);
        }
Exemple #16
0
        public void testUpdateSubscription_CanContainPaypage()
        {
            var update = new updateSubscription();

            update.subscriptionId = 1;
            update.paypage        = new cardPaypageType();
            update.paypage.paypageRegistrationId = "abc123";

            var actual   = update.Serialize();
            var expected = @"
<updateSubscription>
<subscriptionId>1</subscriptionId>
<paypage>
<paypageRegistrationId>abc123</paypageRegistrationId>
</paypage>
</updateSubscription>";

            Assert.AreEqual(expected, actual);
        }
        public void testUpdateSubscription_CanContainUpdateAddOns()
        {
            updateAddOn uao1 = new updateAddOn();
            uao1.addOnCode = "1";
            uao1.name = "addOn1";
            uao1.amount = 100;
            uao1.startDate = new DateTime(2013, 9, 5);
            uao1.endDate = new DateTime(2013, 9, 6);

            updateAddOn uao2 = new updateAddOn();
            uao2.addOnCode = "2";
            uao2.name = "addOn2";
            uao2.amount = 200;
            uao2.startDate = new DateTime(2013, 9, 4);
            uao2.endDate = new DateTime(2013, 9, 5);

            updateSubscription update = new updateSubscription();
            update.subscriptionId = 1;
            update.updateAddOns.Add(uao1);
            update.updateAddOns.Add(uao2);

            String actual = update.Serialize();
            String expected = @"
            <updateSubscription>
            <subscriptionId>1</subscriptionId>
            <updateAddOn>
            <addOnCode>1</addOnCode>
            <name>addOn1</name>
            <amount>100</amount>
            <startDate>2013-09-05</startDate>
            <endDate>2013-09-06</endDate>
            </updateAddOn>
            <updateAddOn>
            <addOnCode>2</addOnCode>
            <name>addOn2</name>
            <amount>200</amount>
            <startDate>2013-09-04</startDate>
            <endDate>2013-09-05</endDate>
            </updateAddOn>
            </updateSubscription>";
            Assert.AreEqual(expected, actual);
        }
        public void testUpdateSubscription_CanContainToken()
        {
            updateSubscription update = new updateSubscription();
            update.subscriptionId = 1;
            update.token = new cardTokenType();
            update.token.litleToken = "123456";

            String actual = update.Serialize();
            String expected = @"
            <updateSubscription>
            <subscriptionId>1</subscriptionId>
            <token>
            <litleToken>123456</litleToken>
            </token>
            </updateSubscription>";
            Assert.AreEqual(expected, actual);
        }
        public void testUpdateSubscription_CanContainPaypage()
        {
            updateSubscription update = new updateSubscription();
            update.subscriptionId = 1;
            update.paypage = new cardPaypageType();
            update.paypage.paypageRegistrationId = "abc123";

            String actual = update.Serialize();
            String expected = @"
            <updateSubscription>
            <subscriptionId>1</subscriptionId>
            <paypage>
            <paypageRegistrationId>abc123</paypageRegistrationId>
            </paypage>
            </updateSubscription>";
            Assert.AreEqual(expected, actual);
        }
        public void testUpdateSubscription_CanContainDeleteDiscounts()
        {
            deleteDiscount dd1 = new deleteDiscount();
            dd1.discountCode = "1";

            deleteDiscount dd2 = new deleteDiscount();
            dd2.discountCode = "2";

            updateSubscription update = new updateSubscription();
            update.subscriptionId = 1;
            update.deleteDiscounts.Add(dd1);
            update.deleteDiscounts.Add(dd2);

            String actual = update.Serialize();
            String expected = @"
            <updateSubscription>
            <subscriptionId>1</subscriptionId>
            <deleteDiscount>
            <discountCode>1</discountCode>
            </deleteDiscount>
            <deleteDiscount>
            <discountCode>2</discountCode>
            </deleteDiscount>
            </updateSubscription>";
            Assert.AreEqual(expected, actual);
        }
        public void testUpdateSubscription_CanContainDeleteAddOns()
        {
            deleteAddOn dao1 = new deleteAddOn();
            dao1.addOnCode = "1";

            deleteAddOn dao2 = new deleteAddOn();
            dao2.addOnCode = "2";

            updateSubscription update = new updateSubscription();
            update.subscriptionId = 1;
            update.deleteAddOns.Add(dao1);
            update.deleteAddOns.Add(dao2);

            String actual = update.Serialize();
            String expected = @"
            <updateSubscription>
            <subscriptionId>1</subscriptionId>
            <deleteAddOn>
            <addOnCode>1</addOnCode>
            </deleteAddOn>
            <deleteAddOn>
            <addOnCode>2</addOnCode>
            </deleteAddOn>
            </updateSubscription>";
            Assert.AreEqual(expected, actual);
        }
        public void testUpdateSubscription_OnlyRequired()
        {
            updateSubscription update = new updateSubscription();
            update.subscriptionId = 12345;

            String actual = update.Serialize();
            String expected = "\r\n<updateSubscription>\r\n<subscriptionId>12345</subscriptionId>\r\n</updateSubscription>";
            Assert.AreEqual(expected, actual);
        }
        public void testUpdateSubscription_CanContainUpdateDiscounts()
        {
            updateDiscount ud1 = new updateDiscount();
            ud1.discountCode = "1";
            ud1.name = "cheaper";
            ud1.amount = 200;
            ud1.startDate = new DateTime(2013, 9, 5);
            ud1.endDate = new DateTime(2013, 9, 6);

            updateDiscount ud2 = new updateDiscount();
            ud2.discountCode = "2";
            ud2.name = "cheap";
            ud2.amount = 100;
            ud2.startDate = new DateTime(2013, 9, 3);
            ud2.endDate = new DateTime(2013, 9, 4);

            updateSubscription update = new updateSubscription();
            update.subscriptionId = 1;
            update.updateDiscounts.Add(ud1);
            update.updateDiscounts.Add(ud2);

            String actual = update.Serialize();
            String expected = @"
            <updateSubscription>
            <subscriptionId>1</subscriptionId>
            <updateDiscount>
            <discountCode>1</discountCode>
            <name>cheaper</name>
            <amount>200</amount>
            <startDate>2013-09-05</startDate>
            <endDate>2013-09-06</endDate>
            </updateDiscount>
            <updateDiscount>
            <discountCode>2</discountCode>
            <name>cheap</name>
            <amount>100</amount>
            <startDate>2013-09-03</startDate>
            <endDate>2013-09-04</endDate>
            </updateDiscount>
            </updateSubscription>";
            Assert.AreEqual(expected, actual);
        }
        public void TestUpdateSubscription_Full()
        {
            updateSubscription update = new updateSubscription();
            update.billingDate = new DateTime(2002, 10, 9);
            contact billToAddress = new contact();
            billToAddress.name = "Greg Dake";
            billToAddress.city = "Lowell";
            billToAddress.state = "MA";
            billToAddress.email = "*****@*****.**";
            update.billToAddress = billToAddress;
            cardType card = new cardType();
            card.number = "4100000000000001";
            card.expDate = "1215";
            card.type = methodOfPaymentTypeEnum.VI;
            update.card = card;
            update.planCode = "abcdefg";
            update.subscriptionId = 12345;

            String actual = update.Serialize();
            String expected = "\r\n<updateSubscription>\r\n<subscriptionId>12345</subscriptionId>\r\n<planCode>abcdefg</planCode>\r\n<billToAddress>\r\n<name>Greg Dake</name>\r\n<city>Lowell</city>\r\n<state>MA</state>\r\n<email>[email protected]</email>\r\n</billToAddress>\r\n<card>\r\n<type>VI</type>\r\n<number>4100000000000001</number>\r\n<expDate>1215</expDate>\r\n</card>\r\n<billingDate>2002-10-09</billingDate>\r\n</updateSubscription>";
            Assert.AreEqual(expected, actual);
        }
        public void testUpdateSubscription()
        {
            updateSubscription update = new updateSubscription();
            update.billingDate = new DateTime(2002, 10, 9);
            contact billToAddress = new contact();
            billToAddress.name = "Greg Dake";
            billToAddress.city = "Lowell";
            billToAddress.state = "MA";
            billToAddress.email = "*****@*****.**";
            update.billToAddress = billToAddress;
            cardType card = new cardType();
            card.number = "4100000000000001";
            card.expDate = "1215";
            card.type = methodOfPaymentTypeEnum.VI;
            update.card = card;
            update.planCode = "abcdefg";
            update.subscriptionId = 12345;

            batchRequest.addUpdateSubscription(update);

            Assert.AreEqual(1, batchRequest.getNumUpdateSubscriptions());

            mockLitleFile.Verify(litleFile => litleFile.createRandomFile(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<String>(), mockLitleTime.Object));
            mockLitleFile.Verify(litleFile => litleFile.AppendLineToFile(mockFilePath, update.Serialize()));
        }