Ejemplo n.º 1
0
        private static StateOrCountryTaxPart GetFrenchTax()
        {
            var frenchTax = new StateOrCountryTaxPart();

            ContentHelpers.PreparePart <StateOrCountryTaxPart, StateOrCountryTaxPartRecord>(frenchTax, "Tax");
            frenchTax.Country = "France";
            frenchTax.Rate    = 0.19;
            return(frenchTax);
        }
Ejemplo n.º 2
0
        private static StateOrCountryTaxPart GetBritishTax()
        {
            var britishTax = new StateOrCountryTaxPart();

            ContentHelpers.PreparePart <StateOrCountryTaxPart, StateOrCountryTaxPartRecord>(britishTax, "Tax");
            britishTax.Country = "United Kingdom (Great Britain and Northern Ireland)";
            britishTax.Rate    = 0.15;
            return(britishTax);
        }
Ejemplo n.º 3
0
        private static StateOrCountryTaxPart GetAnyCountryTax()
        {
            var anyCountryTax = new StateOrCountryTaxPart();

            ContentHelpers.PreparePart <StateOrCountryTaxPart, StateOrCountryTaxPartRecord>(anyCountryTax, "Tax");
            anyCountryTax.Country = "*";
            anyCountryTax.Rate    = 0.07;
            return(anyCountryTax);
        }
Ejemplo n.º 4
0
        private static StateOrCountryTaxPart GetWashingtonTax()
        {
            var washingtonTax = new StateOrCountryTaxPart();

            ContentHelpers.PreparePart <StateOrCountryTaxPart, StateOrCountryTaxPartRecord>(washingtonTax, "Tax");
            washingtonTax.Country = Country.UnitedStates;
            washingtonTax.State   = "WA";
            washingtonTax.Rate    = 0.095;
            return(washingtonTax);
        }
Ejemplo n.º 5
0
        private static StateOrCountryTaxPart GetOregonTax()
        {
            var oregonTax = new StateOrCountryTaxPart();

            ContentHelpers.PreparePart <StateOrCountryTaxPart, StateOrCountryTaxPartRecord>(oregonTax, "Tax");
            oregonTax.Country = Country.UnitedStates;
            oregonTax.State   = "OR";
            oregonTax.Rate    = 0.15;
            return(oregonTax);
        }
Ejemplo n.º 6
0
        public UspsSettingsPart GetSettings()
        {
            var settings = new UspsSettingsPart();

            ContentHelpers.PreparePart(settings, "Site");
            settings.UserId               = _uspsUserId;
            settings.OriginZip            = _originZip;
            settings.CommercialPrices     = _commercialPrices;
            settings.CommercialPlusPrices = _commercialPlusPrices;
            return(settings);
        }
Ejemplo n.º 7
0
 public ProductStub(int id = -1, IEnumerable <int> attributeIds = null)
 {
     ContentHelpers.PreparePart <ProductPart, ProductPartVersionRecord>(this, "Product", id);
     ContentItem.Weld(new InfosetPart());
     ShippingCost = -1;
     if (attributeIds != null)
     {
         var attrPartRecord = new ProductAttributesPartRecord();
         var attrPart       = new ProductAttributesPart {
             Record = attrPartRecord
         };
         ContentItem.Weld(attrPart);
         attrPart.AttributeIds = attributeIds;
     }
 }
Ejemplo n.º 8
0
        public void RightTaxAppliesToTabRates()
        {
            var tabZipTax = new ZipCodeTaxPart();

            ContentHelpers.PreparePart(tabZipTax, "Tax");
            tabZipTax.Rates = TabRates;

            var taxProvider = new FakeTaxProvider(new[] { tabZipTax });
            var cart        = ShoppingCartHelpers.PrepareCart(null, new[] { taxProvider });

            cart.Country = "United States";
            cart.ZipCode = "52412";

            CheckTaxes(cart.Taxes().Amount, 11.12);
        }
Ejemplo n.º 9
0
        public void RightTaxAppliesToCsvRates()
        {
            var csvZipTax = new ZipCodeTaxPart();

            ContentHelpers.PreparePart(csvZipTax, "Tax");
            csvZipTax.Rates = CsvRates;

            var taxProvider = new FakeTaxProvider(new[] { csvZipTax });
            var cart        = ShoppingCartHelpers.PrepareCart(null, new[] { taxProvider });

            cart.Country = "United States";
            cart.ZipCode = "52627";

            CheckTaxes(cart.Taxes().Amount, 6.95);
        }
Ejemplo n.º 10
0
        public void ImportGetAllDefinedProperties()
        {
            var doc    = XElement.Parse(@"
<data>
    <UspsShippingMethodPart
        Name=""Foo""
        Size=""L""
        WidthInInches=""10""
        LengthInInches=""11""
        HeightInInches=""12""
        MaximumWeightInOunces=""1.3""
        MinimumQuantity=""3""
        MaximumQuantity=""7""
        CountDistinct=""true""
        Priority=""14""
        International=""true""
        RegisteredMail=""true""
        Insurance=""false""
        ReturnReceipt=""true""
        CertificateOfMailing=""true""
        ElectronicConfirmation=""true""/>
</data>
");
            var driver = new UspsShippingMethodPartDriver(null) as IContentPartDriver;
            var part   = new UspsShippingMethodPart();

            ContentHelpers.PreparePart <UspsShippingMethodPart, UspsShippingMethodPartRecord>(part, "UspsShippingMethod");
            var context = new ImportContentContext(part.ContentItem, doc, new ImportContentSession(null));

            driver.Importing(context);

            Assert.That(part.Name, Is.EqualTo("Foo"));
            Assert.That(part.Size, Is.EqualTo("L"));
            Assert.That(part.WidthInInches, Is.EqualTo(10));
            Assert.That(part.LengthInInches, Is.EqualTo(11));
            Assert.That(part.HeightInInches, Is.EqualTo(12));
            Assert.That(part.MaximumWeightInOunces, Is.EqualTo(1.3));
            Assert.That(part.MinimumQuantity, Is.EqualTo(3));
            Assert.That(part.MaximumQuantity, Is.EqualTo(7));
            Assert.That(part.CountDistinct, Is.True);
            Assert.That(part.Priority, Is.EqualTo(14));
            Assert.That(part.International, Is.True);
            Assert.That(part.RegisteredMail, Is.True);
            Assert.That(part.Insurance, Is.False);
            Assert.That(part.ReturnReceipt, Is.True);
            Assert.That(part.CertificateOfMailing, Is.True);
            Assert.That(part.ElectronicConfirmation, Is.True);
        }
Ejemplo n.º 11
0
        public void ExportSetsAllAttributes()
        {
            var driver = new UspsShippingMethodPartDriver(null) as IContentPartDriver;
            var part   = new UspsShippingMethodPart();

            ContentHelpers.PreparePart <UspsShippingMethodPart, UspsShippingMethodPartRecord>(part, "UspsShippingMethod");
            part.Name                   = "Foo";
            part.Size                   = "L";
            part.WidthInInches          = 10;
            part.LengthInInches         = 11;
            part.HeightInInches         = 12;
            part.MaximumWeightInOunces  = 1.3;
            part.MinimumQuantity        = 3;
            part.MaximumQuantity        = 7;
            part.CountDistinct          = true;
            part.Priority               = 14;
            part.International          = true;
            part.RegisteredMail         = true;
            part.Insurance              = false;
            part.ReturnReceipt          = true;
            part.CertificateOfMailing   = true;
            part.ElectronicConfirmation = true;

            var doc     = new XElement("data");
            var context = new ExportContentContext(part.ContentItem, doc);

            driver.Exporting(context);
            var el = doc.Element("UspsShippingMethodPart");

            Assert.That(el, Is.Not.Null);
            Assert.That(el.Attr("Name"), Is.EqualTo("Foo"));
            Assert.That(el.Attr("Size"), Is.EqualTo("L"));
            Assert.That(el.Attr("WidthInInches"), Is.EqualTo("10"));
            Assert.That(el.Attr("LengthInInches"), Is.EqualTo("11"));
            Assert.That(el.Attr("HeightInInches"), Is.EqualTo("12"));
            Assert.That(el.Attr("MaximumWeightInOunces"), Is.EqualTo("1.3"));
            Assert.That(el.Attr("MinimumQuantity"), Is.EqualTo("3"));
            Assert.That(el.Attr("MaximumQuantity"), Is.EqualTo("7"));
            Assert.That(el.Attr("CountDistinct"), Is.EqualTo("true"));
            Assert.That(el.Attr("Priority"), Is.EqualTo("14"));
            Assert.That(el.Attr("International"), Is.EqualTo("true"));
            Assert.That(el.Attr("RegisteredMail"), Is.EqualTo("true"));
            Assert.That(el.Attr("Insurance"), Is.EqualTo("false"));
            Assert.That(el.Attr("ReturnReceipt"), Is.EqualTo("true"));
            Assert.That(el.Attr("CertificateOfMailing"), Is.EqualTo("true"));
            Assert.That(el.Attr("ElectronicConfirmation"), Is.EqualTo("true"));
        }
Ejemplo n.º 12
0
        public void TaxDoesNotApplyToNonMatchingZip()
        {
            var csvZipTax = new ZipCodeTaxPart();

            ContentHelpers.PreparePart(csvZipTax, "Tax");
            csvZipTax.Rates = CsvRates;

            var taxProvider = new FakeTaxProvider(new[] { csvZipTax });
            var cart        = ShoppingCartHelpers.PrepareCart(null, new[] { taxProvider });

            cart.Country = "United States";
            cart.ZipCode = "90210";

            var taxes = cart.Taxes();

            Assert.AreEqual(0, taxes.Amount);
            Assert.IsNull(taxes.Name);
        }
Ejemplo n.º 13
0
        public void TabRatesAreParsedCorrectly()
        {
            var tabZipTax = new ZipCodeTaxPart();

            ContentHelpers.PreparePart(tabZipTax, "Tax");
            tabZipTax.Rates = TabRates;

            var Rates   = tabZipTax.GetRates();
            var rKeys   = Rates.Keys.ToArray();
            var rValues = Rates.Values.ToArray();

            Assert.That(Rates.Count, Is.EqualTo(4));
            Assert.That(rKeys[0], Is.EqualTo("52411"));
            Assert.That(rValues[0], Is.EqualTo(.07M));
            Assert.That(rKeys[1], Is.EqualTo("52627"));
            Assert.That(rValues[1], Is.EqualTo(.05M));
            Assert.That(rKeys[2], Is.EqualTo("52405"));
            Assert.That(rValues[2], Is.EqualTo(.1M));
            Assert.That(rKeys[3], Is.EqualTo("52412"));
            Assert.That(rValues[3], Is.EqualTo(.08M));
        }