public void GetPolularityTable() { var popularityService = new ProductPopularityService(_configuration, new ProductPopularityCache()); var table = popularityService.GetPolularityTable(); Assert.NotNull(table); Assert.NotEmpty(table); }
public void ApplySortByRecommendedTest(List <Product> products) { var cache = new ProductPopularityCache(); cache.Refresh(new Dictionary <string, decimal>() { { "Test Product A", 1.0m }, { "Test Product B", 2.0m }, { "Test Product C", 3.0m }, { "Test Product D", 4.0m }, { "Test Product F", 5.0m }, }); var popularityService = new ProductPopularityService(_configuration, cache); var productSortManager = new ProductSortManager(); productSortManager.RegisterComplexSorter("recommended", new ProductRecommendedSort(popularityService)); productSortManager.ApplySort(products, "Recommended"); Assert.Equal("Test Product F", products[0].Name); Assert.Equal("Test Product D", products[1].Name); Assert.Equal("Test Product C", products[2].Name); Assert.Equal("Test Product B", products[3].Name); Assert.Equal("Test Product A", products[4].Name); }