private void TestSuccess(ProductSearchCreteria searchCreteria, IEnumerable <ProductIdentifiable> expectedResults) { ProductSearchResults?results = MarketBridge.SearchProducts(searchCreteria); Assert.IsNotNull(results); Assert.IsNull(results !.TypoFixes, $"expected no typo fixes"); Assert.IsTrue(results !.IsValid(), $"expect valid results (valid IDs)"); new Assert_SetEquals <ProductIdentifiable> ( expectedResults, ProductIdentifiable.DeepEquals ).AssertEquals(results); }
public ProductSearchResults?SearchProducts(ProductSearchCreteria creteria) { ICollection <ProductData>?results = marketProductsService.FindProducts ( creteria.Keywords, (int)Math.Floor(creteria.PriceRange_Low), (int)Math.Ceiling(creteria.PriceRange_High), (int)creteria.ProductRating, creteria.Category ).Result; return(new ProductSearchResults(results.Select(ProductIdentifiable.FromProductData), null)); }
public async Task <ActionResult <IEnumerable <ProductSearchDTO> > > Search([FromQuery] ProductSearchCreteria searchCreteria) { if (searchCreteria == null) { return(BadRequest()); } IEnumerable <ProductData> products = await MarketProductsService.FindProducts ( searchCreteria.Keywords, searchCreteria.PriceRange_Low, searchCreteria.PriceRange_High, searchCreteria.ProductRating, searchCreteria.Category ); if (products == null) { return(InternalServerError()); } return(Ok(products.Select(ProductSearchDTO.FromProductData))); }
public ProductSearchResults?SearchProducts(ProductSearchCreteria creteria) { return(RealBridge?.SearchProducts(creteria)); }