Beispiel #1
0
        private void ConfigureAndCreateEntitiesBeforeRunningTests()
        {
            //update current project to support these languages
            var project = this.ChangeProjectLanguages(new List <string> {
                "en", "de"
            });

            Assert.Equal(2, project.Languages.Count);
            Assert.True(project.Languages.Contains("en") && project.Languages.Contains("de"));

            //Fill entities
            this.FillCategories();
            this.FillProducts();
            var allProductIds = AvailableProducts.Select(product => product.Id).ToArray();

            var searchRequest = new SearchProductProjectionsCommand();

            searchRequest.SetStaged(true);
            searchRequest.FilterQuery(p => p.Id.In(allProductIds));
            IClient commerceToolsClient = this.GetService <IClient>();

            //wait till elastic search index refreshed with created products
            AssertEventually(() =>
            {
                var searchResults = commerceToolsClient.ExecuteAsync(searchRequest).Result;
                Assert.Equal(allProductIds.Length, searchResults.Results.Count);
            });
        }
Beispiel #2
0
        public void GetProductProjectionsFilterQueryByCentAmountRange()
        {
            IClient commerceToolsClient = this.productFixture.GetService <IClient>();
            SearchProductProjectionsCommand searchProductProjectionsCommand = new SearchProductProjectionsCommand();

            searchProductProjectionsCommand.FilterQuery(p =>
                                                        p.Variants.Any(v => v.Price.Value.CentAmount.Range(1, 3000)));
            PagedQueryResult <ProductProjection> results = commerceToolsClient.ExecuteAsync(searchProductProjectionsCommand).Result;

            Assert.Equal(19, results.Count);
        }
        /// <summary>
        /// check if all the products used in search tests are indexed
        /// </summary>
        /// <returns>true if the products used in search tests are indexed</returns>
        private bool CheckIfProductsIndexed()
        {
            if (AvailableProductType == null)
            {
                return(false);
            }

            var searchRequest = new SearchProductProjectionsCommand();

            searchRequest.SetStaged(SearchForStaged);
            searchRequest.FilterQuery(p => p.ProductType.Id == AvailableProductType.Id.valueOf());
            var searchResults = client.ExecuteAsync(searchRequest).Result;
            var indexed       = searchResults.Count >= ExpectedProductsCount;

            if (indexed)
            {
                AvailableProducts = searchResults.Results;
            }

            return(indexed);
        }