public void CartPredicateCustomField() { Expression <Func <Cart, bool> > expression = c => c.LineItemCount(l => l.Custom.Fields["age"].ToString() == "adult") >= 2 && c.LineItemCount(l => l.Custom.Fields["age"].ToString() == "youth") >= 1; IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("lineItemCount(custom.age = \"adult\") >= 2 and lineItemCount(custom.age = \"youth\") >= 1", result); }
public void CustomLineItemPredicateCustomFieldReferenceType() { Expression <Func <CustomLineItem, bool> > expression = c => c.Custom.Fields["reference-field"].ToString() == "bac1a3a5-3807-4f5b-9d07-0611984ecae8"; IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("custom.`reference-field` = \"bac1a3a5-3807-4f5b-9d07-0611984ecae8\"", result); }
public void CartPredicateCustomTypeId() { Expression <Func <Cart, bool> > expression = c => c.Custom.Type.Id == "f6a19a23-14e3-40d0-aee2-3e612fcb1bc7"; IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("custom.type.id = \"f6a19a23-14e3-40d0-aee2-3e612fcb1bc7\"", result); }
public void CustomLineItemPredicateCustomFieldStartWithNumber() { Expression <Func <CustomLineItem, bool> > expression = c => c.Custom.Fields["4brand"].ToString() == "adidas"; IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("custom.`4brand` = \"adidas\"", result); }
public void CustomLineItemPredicateCustomFieldMoneyCentAmount() { Expression <Func <CustomLineItem, bool> > expression = c => c.Custom.Fields["price"].ToMoney().CentAmount == 18; IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("custom.price.centAmount = 18", result); }
public void LineItemPredicateCategoriesIdNotEqual() { Expression <Func <LineItem, bool> > expression = l => l.CategoriesId().IsNotIn("f6a19a23-14e3-40d0-aee2-3e612fcb1bc7"); IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("categories.id != (\"f6a19a23-14e3-40d0-aee2-3e612fcb1bc7\")", result); }
public void CustomLineItemPredicateMoneyAndTaxRate() { Expression <Func <CustomLineItem, bool> > expression = c => c.Money > Money.FromDecimal("EUR", 10.51M, MidpointRounding.ToEven).moneyString() && c.TaxRate.IncludedInPrice == false; IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("money > \"10.51 EUR\" and taxRate.includedInPrice = false", result); }
public void LineItemPredicateMoneyAttributeCast() { Expression <Func <LineItem, bool> > expression = l => l.Attributes().Any(a => a.Name == "money" && a.ToMoneyAttribute().Value >= Money.FromDecimal("EUR", 18, MidpointRounding.ToEven).moneyString()); IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("attributes.money >= \"18 EUR\"", result); }
public void LineItemPredicateTextAttributeCaseSensitive() { Expression <Func <LineItem, bool> > expression = l => l.Attributes().Any(a => a.Name == "Color" && ((TextAttribute)a).Value == "Green"); IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("attributes.Color = \"Green\"", result); }
public void LineItemPredicateVariantId() { Expression <Func <LineItem, bool> > expression = l => l.VariantId() == 123; IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("variant.id = 123", result); }
public void LineItemPredicateVariantKey() { Expression <Func <LineItem, bool> > expression = l => l.VariantKey() == "blue_shirt"; IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("variant.key = \"blue_shirt\"", result); }
public void CartPredicateCustomerInformation() { Expression <Func <Cart, bool> > expression = c => c.Customer().Email == "*****@*****.**" && c.Customer().CustomerGroup.Id == "f6a19a23-14e3-40d0-aee2-3e612fcb1bc7"; IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("customer.email = \"[email protected]\" and customer.customerGroup.id = \"f6a19a23-14e3-40d0-aee2-3e612fcb1bc7\"", result); }
public void LineItemCountByProductIdGreaterThanTen() { Expression <Func <Cart, bool> > expression = c => c.LineItemCount(l => l.ProductId == "45224437-12bd-4742-830c-3a36b52541d3") > 10; IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("lineItemCount(product.id = \"45224437-12bd-4742-830c-3a36b52541d3\") > 10", result); }
public void CartPredicateTotalGross() { Expression <Func <Cart, bool> > expression = c => c.TaxedPrice.TotalGross <= Money.FromDecimal("USD", 10, MidpointRounding.ToEven).moneyString(); IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("taxedPrice.gross <= \"10 USD\"", result); }
public void LineItemPredicateGrouping() { Expression <Func <LineItem, bool> > expression = l => l.ProductType.Id == "f6a19a23-14e3-40d0-aee2-3e612fcb1bc7" && l.Attributes().Any(a => a.Name == "rating" && ((NumberAttribute)a).Value > 3) && (l.ProductId == "abcd9a23-14e3-40d0-aee2-3e612fcbefgh" || l.ProductId == "ba3e4ee7-30fa-400b-8155-46ebf423d793"); IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("productType.id = \"f6a19a23-14e3-40d0-aee2-3e612fcb1bc7\" and attributes.rating > 3 and (product.id = \"abcd9a23-14e3-40d0-aee2-3e612fcbefgh\" or product.id = \"ba3e4ee7-30fa-400b-8155-46ebf423d793\")", result); }
public void CartPredicateCountryIsDefined() { Expression <Func <Cart, bool> > expression = c => c.Country.IsDefined(); IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("country is defined", result); }
public void LineItemPredicateCustomField() { Expression <Func <LineItem, bool> > expression = l => l.Custom.Fields["gender"].ToString() == "alien"; IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("custom.gender = \"alien\"", result); }
public void LineItemCountTrueGreaterThanTen() { Expression <Func <Cart, bool> > expression = c => c.LineItemCount(true) > 10; IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("lineItemCount(true) > 10", result); }
public void LineItemCountWithPredicate() { Expression <Func <Cart, bool> > expression = c => c.LineItemCount(l => l.Attributes().Any(a => a.Name == "size" && a.ToTextAttribute().Value.In("xxl", "xl"))) == 2; IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("lineItemCount(attributes.size in (\"xxl\", \"xl\")) = 2", result); }
public void LineItemPredicateEnumSetContainsAnyAttribute() { Expression <Func <LineItem, bool> > expression = l => l.Attributes().Any(a => a.Name == "colors" && ((SetEnumAttribute)a).Value.Select(e => e.Key).ContainsAny("green", "blue")); IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("attributes.colors contains any (\"green\", \"blue\")", result); }
public void CustomLineItemPredicateSlug() { Expression <Func <CustomLineItem, bool> > expression = c => c.Slug == "adidas-superstar-2"; IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("slug = \"adidas-superstar-2\"", result); }
public void LineItemPredicatePriceCentAmount() { Expression <Func <LineItem, bool> > expression = l => l.Price.Value.CentAmount == 1000; IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("price.centAmount = 1000", result); }
public void CustomLineItemPredicateCustomFieldMoney() { Expression <Func <CustomLineItem, bool> > expression = c => c.Custom.Fields["price"].ToString() == "18.00 EUR"; IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("custom.price = \"18.00 EUR\"", result); }
public void LineItemPredicatePriceDiscountId() { Expression <Func <LineItem, bool> > expression = l => l.Price.DiscountId() == "45224437-12bd-4742-830c-3a36b52541d3"; IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("price.discount.id = \"45224437-12bd-4742-830c-3a36b52541d3\"", result); }
public void LineItemPredicatePriceNot() { Expression <Func <LineItem, bool> > expression = l => !(l.Price.Value == Money.FromDecimal("EUR", 10, MidpointRounding.ToEven).moneyString()); IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("not(price = \"10 EUR\")", result); }
public void LineItemPredicatePriceCustomerGroupKey() { Expression <Func <LineItem, bool> > expression = l => l.Price.CustomerGroupKey() == "key123"; IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("price.customerGroup.key = \"key123\"", result); }
public void CustomLineItemPredicateCustomFieldReferenceTypeInCollection() { Expression <Func <CustomLineItem, bool> > expression = c => c.Custom.Fields["reference-field"].ContainsAny("bac1a3a5-3807-4f5b-9d07-0611984ecae8", "f6a19a23-14e3-40d0-aee2-3e612fcb1bc7"); IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("custom.`reference-field` contains any (\"bac1a3a5-3807-4f5b-9d07-0611984ecae8\", \"f6a19a23-14e3-40d0-aee2-3e612fcb1bc7\")", result); }
public void LineItemPredicateSkuAndTaxRate() { Expression <Func <LineItem, bool> > expression = l => l.Sku() == "SKU-123" && l.TaxRate.IncludedInPrice == false; IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("sku = \"SKU-123\" and taxRate.includedInPrice = false", result); }
public void CartPredicateCurrency() { Expression <Func <Cart, bool> > expression = c => c.Currency() == "EUR"; IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("currency = \"EUR\"", result); }
public void CartPredicateCustomTypeKey() { Expression <Func <Cart, bool> > expression = c => c.CustomTypeKey() == "my-category"; IDiscountPredicateExpressionVisitor cartPredicateExpressionVisitor = this.linqFixture.GetService <IDiscountPredicateExpressionVisitor>(); var result = cartPredicateExpressionVisitor.Render(expression); Assert.Equal("custom.type.key = \"my-category\"", result); }