コード例 #1
0
ファイル: SearchFilter.cs プロジェクト: cr0c0pk1/bikes-bg
        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);
            }
        }
コード例 #2
0
        public IActionResult Search(SearchAdViewModel model)
        {
            AdFilterService adFilter = new AdFilterService(advertisementRepo);

            model.advertisements = adFilter.GetAdsByFilter(model.searchFilter);
            LoadFilterData(model.searchFilter);
            return(View(model));
        }
コード例 #3
0
ファイル: SearchFilter.cs プロジェクト: cr0c0pk1/bikes-bg
        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);
            }
        }