Ejemplo n.º 1
0
        public void TestFormatFixedDiscountRows()
        {
            CreateOrderBuilder order = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig())
                                       .AddDiscount(Item.FixedDiscount()
                                                    .SetDiscountId("0")
                                                    .SetName("Tess")
                                                    .SetDescription("Tester")
                                                    .SetUnit("st"));

            List <HostedOrderRowBuilder> newRows = new HostedRowFormatter <CreateOrderBuilder>().FormatRows(order);
            HostedOrderRowBuilder        newRow  = newRows[0];

            Assert.That(newRow.GetSku(), Is.EqualTo("0"));
            Assert.That(newRow.GetName(), Is.EqualTo("Tess"));
            Assert.That(newRow.GetDescription(), Is.EqualTo("Tester"));
            Assert.That(newRow.GetQuantity(), Is.EqualTo(1));
            Assert.That(newRow.GetUnit(), Is.EqualTo("st"));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// SerializeRow
        /// </summary>
        /// <param name="row"></param>
        /// <param name="xmlw"></param>
        private void SerializeRow(HostedOrderRowBuilder row, XmlWriter xmlw)
        {
            xmlw.WriteStartElement("row");

            WriteSimpleElement("sku", row.GetSku() ?? "", xmlw);
            WriteSimpleElement("name", row.GetName() ?? "", xmlw);
            WriteSimpleElement("description", row.GetDescription() ?? "", xmlw);

            WriteSimpleElement("amount", row.GetAmount().ToString(CultureInfo.InvariantCulture), xmlw);
            WriteSimpleElement("vat", row.GetVat().ToString(CultureInfo.InvariantCulture), xmlw);

            if (row.GetQuantity() > 0)
            {
                WriteSimpleElement("quantity", row.GetQuantity().ToString(CultureInfo.InvariantCulture), xmlw);
            }

            WriteSimpleElement("unit", row.GetUnit(), xmlw);

            xmlw.WriteEndElement();
        }
Ejemplo n.º 3
0
        public void TestFormatOrderRows()
        {
            CreateOrderBuilder order = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig())
                                       .AddOrderRow(Item.OrderRow()
                                                    .SetArticleNumber("0")
                                                    .SetName("Tess")
                                                    .SetDescription("Tester")
                                                    .SetAmountExVat(4)
                                                    .SetVatPercent(25)
                                                    .SetQuantity(1)
                                                    .SetUnit("st"));

            List <HostedOrderRowBuilder> newRows = new HostedRowFormatter <CreateOrderBuilder>().FormatRows(order);
            HostedOrderRowBuilder        newRow  = newRows[0];

            Assert.That(newRow.GetSku(), Is.EqualTo("0"));
            Assert.That(newRow.GetName(), Is.EqualTo("Tess"));
            Assert.That(newRow.GetDescription(), Is.EqualTo("Tester"));
            Assert.That(newRow.GetAmount(), Is.EqualTo(500L));
            Assert.That(newRow.GetVat(), Is.EqualTo(100));
            Assert.That(newRow.GetQuantity(), Is.EqualTo(1));
            Assert.That(newRow.GetUnit(), Is.EqualTo("st"));
        }
        /// <summary>
        /// SerializeRow
        /// </summary>
        /// <param name="row"></param>
        /// <param name="xmlw"></param>
        private void SerializeRow(HostedOrderRowBuilder row, XmlWriter xmlw)
        {
            xmlw.WriteStartElement("row");

            WriteSimpleElement("sku", row.GetSku() ?? "", xmlw);
            WriteSimpleElement("name", row.GetName() ?? "", xmlw);
            WriteSimpleElement("description", row.GetDescription() ?? "", xmlw);

            WriteSimpleElement("amount", row.GetAmount().ToString(CultureInfo.InvariantCulture), xmlw);
            WriteSimpleElement("vat", row.GetVat().ToString(CultureInfo.InvariantCulture), xmlw);

            if (row.GetQuantity() > 0)
            {
                WriteSimpleElement("quantity", row.GetQuantity().ToString(CultureInfo.InvariantCulture), xmlw);
            }

            WriteSimpleElement("unit", row.GetUnit(), xmlw);

            xmlw.WriteEndElement();
        }