public void PriceFromTo() { // Arrange int expectedPriceFrom = 1000; int expectedPriceTo = 2000; AdSearchFilter filter = new AdSearchFilter { priceFrom = expectedPriceFrom, priceTo = expectedPriceTo }; var serviceProvider = GetServiceProvider(); var AdRepository = serviceProvider.GetService <IGenericRepository <Advertisement> >(); AdFilterService adFilterService = new AdFilterService(AdRepository); // Act var advertisementsList = adFilterService.GetAdsByFilter(filter); // Assert for (int i = 0; i < advertisementsList.Count; i++) { Assert.IsTrue(advertisementsList[i].price >= expectedPriceFrom); Assert.IsTrue(advertisementsList[i].price <= expectedPriceTo); } }
public IActionResult Search(SearchAdViewModel model) { AdFilterService adFilter = new AdFilterService(advertisementRepo); model.advertisements = adFilter.GetAdsByFilter(model.searchFilter); LoadFilterData(model.searchFilter); return(View(model)); }
public void BrandSelected() { // Arrange int expectedBrandId = 2; AdSearchFilter filter = new AdSearchFilter { brandId = expectedBrandId }; var serviceProvider = GetServiceProvider(); var AdRepository = serviceProvider.GetService <IGenericRepository <Advertisement> >(); AdFilterService adFilterService = new AdFilterService(AdRepository); // Act var advertisementsList = adFilterService.GetAdsByFilter(filter); // Assert for (int i = 0; i < advertisementsList.Count; i++) { Assert.IsTrue(advertisementsList[i].bikeModel.brandID == expectedBrandId); } }