public void FilterByScopedPriceDiscountedValue() { Expression <Func <ProductProjection, bool> > expression = p => p.Variants.Any(v => v.ScopedPrice.Discounted.Value.CentAmount.Range(1, 30)); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); var result = filterExpressionVisitor.Render(expression); Assert.Equal("variants.scopedPrice.discounted.value.centAmount:range (1 to 30)", result); }
public void TermFacetAttributeLocalizedEnum() { Expression <Func <ProductProjection, string> > expression = p => p.Variants.Select(v => v.Attributes.Where(a => a.Name == "color").Select(a => ((LocalizedEnumAttribute)a).Value.Label["en"]).FirstOrDefault()).FirstOrDefault(); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); string result = filterExpressionVisitor.Render(expression); Assert.Equal("variants.attributes.color.label.en", result); }
public void TermFacetAverageRating() { Expression <Func <ProductProjection, double> > expression = p => p.ReviewRatingStatistics.AverageRating; IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); string result = filterExpressionVisitor.Render(expression); Assert.Equal("reviewRatingStatistics.averageRating", result); }
public void FilterFacetCategoryId() { Expression <Func <ProductProjection, bool> > expression = p => p.Categories.Any(c => c.Id == "34940e9b-0752-4ffa-8e6e-4f2417995a3e"); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); string result = filterExpressionVisitor.Render(expression); Assert.Equal("categories.id:\"34940e9b-0752-4ffa-8e6e-4f2417995a3e\"", result); }
public void FilterFacetAttributeIn() { Expression <Func <ProductProjection, bool> > expression = p => p.Variants.Any(v => v.Attributes.Any(a => a.Name == "color" && ((TextAttribute)a).Value.In("red", "green"))); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); string result = filterExpressionVisitor.Render(expression); Assert.Equal("variants.attributes.color:\"red\",\"green\"", result); }
public void FilteredFacetCategoryInTwoSubtrees() { Expression <Func <ProductProjection, bool> > expression = p => p.Categories.Any(c => c.Id.Subtree("34940e9b-0752-4ffa-8e6e-4f2417995a3e") || c.Id.Subtree("2fd1d652-2533-40f1-97d7-713ac24668b1")); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); var result = filterExpressionVisitor.Render(expression); Assert.Equal("categories.id: subtree(\"34940e9b-0752-4ffa-8e6e-4f2417995a3e\"), subtree(\"2fd1d652-2533-40f1-97d7-713ac24668b1\")", result); }
public void TermFacetAttributeMoneyCentAmount() { Expression <Func <ProductProjection, string> > expression = p => p.Variants.Select(v => v.Attributes.Where(a => a.Name == "customMoney").Select(a => ((MoneyAttribute)a).Value.CentAmount.ToString()).FirstOrDefault()).FirstOrDefault(); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); string result = filterExpressionVisitor.Render(expression); Assert.Equal("variants.attributes.customMoney.centAmount", result); }
public void FilterByIsOnStock() { Expression <Func <ProductProjection, bool> > expression = p => p.Variants.Any(v => v.Availability.IsOnStock == true); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); var result = filterExpressionVisitor.Render(expression); Assert.Equal("variants.availability.isOnStock:true", result); }
public void FilterByIsOnStockPerChannel() { Expression <Func <ProductProjection, bool> > expression = p => p.Variants.Any(v => v.Availability.Channels["1a3c451e-792a-43b5-8def-88d0db22eca8"].IsOnStock == true); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); var result = filterExpressionVisitor.Render(expression); Assert.Equal("variants.availability.channels.1a3c451e-792a-43b5-8def-88d0db22eca8.isOnStock:true", result); }
public void FilterByNumberAttributeExists() { Expression <Func <ProductProjection, bool> > expression = p => p.Variants.Any(v => v.Attributes.Where(a => a.Name == "size").Exists()); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); var result = filterExpressionVisitor.Render(expression); Assert.Equal("variants.attributes.size:exists", result); }
public void FilterByEnumAttribute() { Expression <Func <ProductProjection, bool> > expression = p => p.Variants.Any(v => v.Attributes.Any(a => a.Name == "color" && ((EnumAttribute)a).Value.Key == "grey")); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); var result = filterExpressionVisitor.Render(expression); Assert.Equal("variants.attributes.color.key:\"grey\"", result); }
public void FilterByLocalizedTextAttributeValue() { Expression <Func <ProductProjection, bool> > expression = p => p.Variants.Any(v => v.Attributes.Any(a => a.Name == "color" && ((LocalizedTextAttribute)a).Value["en"] == "red")); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); var result = filterExpressionVisitor.Render(expression); Assert.Equal("variants.attributes.color.en:\"red\"", result); }
public void FilterByPricesExists() { Expression <Func <ProductProjection, bool> > expression = p => p.Variants.Any(v => v.Prices.Exists()); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); var result = filterExpressionVisitor.Render(expression); Assert.Equal("variants.prices:exists", result); }
public void FilterByPriceCentAmountUpperBoundUnknownRange() { Expression <Func <ProductProjection, bool> > expression = p => p.Variants.Any(v => v.Price.Value.CentAmount.Range(1, null)); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); var result = filterExpressionVisitor.Render(expression); Assert.Equal("variants.price.centAmount:range (1 to *)", result); }
public void FilterByCategorySubtreeTwoIds() { Expression <Func <ProductProjection, bool> > expression = p => p.Categories.Any(c => c.Id.Subtree("34940e9b-0752-4ffa-8e6e-4f2417995a3e") || c.Id == "2fd1d652-2533-40f1-97d7-713ac24668b1" || c.Id == "51e7da39-4946-4c1d-a948-af7b54874891"); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); var result = filterExpressionVisitor.Render(expression); Assert.Equal("categories.id: subtree(\"34940e9b-0752-4ffa-8e6e-4f2417995a3e\"),\"2fd1d652-2533-40f1-97d7-713ac24668b1\",\"51e7da39-4946-4c1d-a948-af7b54874891\"", result); }
public void FilterByAvailabilityIsOnStockInChannels() { Expression <Func <ProductProjection, bool> > expression = p => p.Variants.Any(v => v.Availability.IsOnStockInChannels("1a3c451e-792a-43b5-8def-88d0db22eca8", "110321ab-8fd7-4d4c-8b7c-4c69761411fc")); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); var result = filterExpressionVisitor.Render(expression); Assert.Equal("variants.availability.isOnStockInChannels:\"1a3c451e-792a-43b5-8def-88d0db22eca8\",\"110321ab-8fd7-4d4c-8b7c-4c69761411fc\"", result); }
public void RangeFacetCustomAttribute() { Expression <Func <ProductProjection, bool> > expression = p => p.Variants.Any(v => v.Attributes.Any(a => a.Name == "size" && ((NumberAttribute)a).Value.Range(36, 42))); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); string result = filterExpressionVisitor.Render(expression); Assert.Equal("variants.attributes.size:range (36 to 42)", result); }
public void FilterBySearchKeywords() { Expression <Func <ProductProjection, bool> > expression = p => p.SearchKeywords["en"].Any(s => s.Text == "jeans"); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); var result = filterExpressionVisitor.Render(expression); Assert.Equal("searchKeywords.en.text:\"jeans\"", result); }
public void FilteredFacetBySpecificPrice() { Expression <Func <ProductProjection, bool> > expression = p => p.Variants.Any(v => v.Price.Value.CentAmount == 30); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); string result = filterExpressionVisitor.Render(expression); Assert.Equal("variants.price.centAmount:30", result); }
public void FilterAttributeNameCaseSensitive() { Expression <Func <ProductProjection, bool> > expression = p => p.Variants.Any(v => v.Attributes.Any(a => a.Name == "Color" && ((TextAttribute)a).Value == "Red")); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); var result = filterExpressionVisitor.Render(expression); Assert.Equal("variants.attributes.Color:\"Red\"", result); }
public void TermFacetAvailableQuantity() { Expression <Func <ProductProjection, long> > expression = p => p.Variants.Select(v => v.Availability.AvailableQuantity).FirstOrDefault(); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); string result = filterExpressionVisitor.Render(expression); Assert.Equal("variants.availability.availableQuantity", result); }
public void FilterByCreatedAt() { Expression <Func <ProductProjection, bool> > expression = p => p.CreatedAt.Range(DateTime.Parse("2015-06-04T12:27:55.344Z"), DateTime.Parse("2016-06-04T12:27:55.344Z")); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); var result = filterExpressionVisitor.Render(expression); Assert.Equal("createdAt:range (\"2015-06-04T12:27:55.344Z\" to \"2016-06-04T12:27:55.344Z\")", result); }
public void FilterFacetCategoryAllSubtrees() { Expression <Func <ProductProjection, bool> > expression = p => p.Categories.Any(c => c.Id.Subtree("*")); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); string result = filterExpressionVisitor.Render(expression); Assert.Equal("categories.id: subtree(\"*\")", result); }
public void FilterByTaxCategoryMissing() { Expression <Func <ProductProjection, bool> > expression = p => p.TaxCategory.Missing(); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); var result = filterExpressionVisitor.Render(expression); Assert.Equal("taxCategory:missing", result); }
public void TermFacetAttributeText() { Expression <Func <ProductProjection, string> > expression = p => p.Variants.Select(v => v.Attributes.Where(a => a.Name == "size").Select(a => ((TextAttribute)a).Value).FirstOrDefault()).FirstOrDefault(); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); string result = filterExpressionVisitor.Render(expression); Assert.Equal("variants.attributes.size", result); }
public void FilterByCategoryExists() { Expression <Func <ProductProjection, bool> > expression = p => p.Categories.Exists(); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); var result = filterExpressionVisitor.Render(expression); Assert.Equal("categories:exists", result); }
public void TermFacetChannelAvailableQuantity() { Expression <Func <ProductProjection, int> > expression = p => p.Variants.Select(v => v.Availability.Channels["1a3c451e-792a-43b5-8def-88d0db22eca8"].AvailableQuantity).FirstOrDefault(); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); string result = filterExpressionVisitor.Render(expression); Assert.Equal("variants.availability.channels.1a3c451e-792a-43b5-8def-88d0db22eca8.availableQuantity", result); }
public void FilterByCategorySubtree() { Expression <Func <ProductProjection, bool> > expression = p => p.Categories.Any(c => c.Id.Subtree("34940e9b-0752-4ffa-8e6e-4f2417995a3e")); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); var result = filterExpressionVisitor.Render(expression); Assert.Equal("categories.id: subtree(\"34940e9b-0752-4ffa-8e6e-4f2417995a3e\")", result); }
public void RangeFacetCentAmount() { Expression <Func <ProductProjection, bool> > expression = p => p.Variants.Any(v => v.Price.Value.CentAmount.Range(1, 30)); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); string result = filterExpressionVisitor.Render(expression); Assert.Equal("variants.price.centAmount:range (1 to 30)", result); }
public void FilterByScopedPriceCurrentValue() { Expression <Func <ProductProjection, bool> > expression = p => p.Variants.Any(v => v.ScopedPrice.CurrentValue.CentAmount == 1000); IFilterPredicateExpressionVisitor filterExpressionVisitor = this.linqFixture.GetService <IFilterPredicateExpressionVisitor>(); var result = filterExpressionVisitor.Render(expression); Assert.Equal("variants.scopedPrice.currentValue.centAmount:1000", result); }