コード例 #1
0
        public void GetGamesByFilter_FilterByDateTwoYear_GetedGames()
        {
            var filterDto = new FilterDTO()
            {
                FilterDate = FilterDate.twoYear
            };
            var gamePipeline = new GamePipeline();

            gamePipeline.Register(new GameFilterByDate(filterDto.FilterDate));
            var gamesAfteFilter = gamePipeline.Process(_fakeGamesForFilter);

            Assert.True(gamesAfteFilter.ElementAt(0).PublishDate > gamesAfteFilter.ElementAt(1).PublishDate);
        }
コード例 #2
0
        public void GetGamesByFilter_FilterByDateMonth_GetedGames()
        {
            var filterDto = new FilterDTO()
            {
                FilterDate = FilterDate.month
            };
            var gamePipeline = new GamePipeline();

            gamePipeline.Register(new GameFilterByDate(filterDto.FilterDate));
            var gamesAfteFilter = gamePipeline.Process(_fakeGamesForFilter);

            Assert.True(gamesAfteFilter.ElementAt(0).PublishDate >= DateTime.Today.AddMonths(-1));
        }
コード例 #3
0
        public void GetGamesByFilter_FilterByDateWeek_GetedGames()
        {
            var filterDto = new FilterDTO()
            {
                FilterDate = FilterDate.week
            };
            var gamePipeline = new GamePipeline();

            gamePipeline.Register(new GameFilterByDate(filterDto.FilterDate));
            var gamesAfteFilter = gamePipeline.Process(_fakeGamesForFilter);

            Assert.True(gamesAfteFilter.First().PublishDate >= DateTime.Today.AddDays(-7));
        }
コード例 #4
0
        public void GetGamesByFilter_SortFilterMostPopular_GetedGames()
        {
            var filterDto = new FilterDTO()
            {
                SortType = SortType.MostPopular
            };
            var gamePipeline = new GamePipeline();

            gamePipeline.Register(new GameSortFilter(filterDto.SortType));
            var gamesAfteFilter = gamePipeline.Process(_fakeGamesForFilter);

            Assert.True(gamesAfteFilter.ElementAt(0).Views > gamesAfteFilter.ElementAt(1).Views);
        }
コード例 #5
0
        public void GetGamesByFilter_SortFilterPriceAsc_GetedGames()
        {
            var filterDto = new FilterDTO()
            {
                SortType = SortType.PriceAsc
            };
            var gamePipeline = new GamePipeline();

            gamePipeline.Register(new GameSortFilter(filterDto.SortType));
            var gamesAfteFilter = gamePipeline.Process(_fakeGamesForFilter);

            Assert.True(gamesAfteFilter.ElementAt(0).Price < gamesAfteFilter.ElementAt(1).Price);
        }
コード例 #6
0
        public void GetGamesByFilter_FilterByFilterByMinPrice_GetedGames()
        {
            var filterDto = new FilterDTO()
            {
                MaxPrice = 30
            };
            var gamePipeline = new GamePipeline();

            gamePipeline.Register(new GameFilterByPrice(filterDto.MaxPrice.Value, null));
            var gamesAfteFilter = gamePipeline.Process(_fakeGamesForFilter);

            Assert.Equal(_fakeGamesForFilter.Count, gamesAfteFilter.Count());
        }
コード例 #7
0
        public void GetGamesByFilter_FilterByName_GetedGames()
        {
            var filterDto = new FilterDTO()
            {
                SearchGameName = "game"
            };
            var gamePipeline = new GamePipeline();

            gamePipeline.Register(new GameFilterByName(filterDto.SearchGameName));
            var gamesAfteFilter = gamePipeline.Process(_fakeGamesForFilter);

            Assert.Equal(_fakeGamesForFilter.Count, gamesAfteFilter.Count());
        }
コード例 #8
0
        public void GetGamesByFilter_FilterByPublisher_GetedGames()
        {
            var filterDto = new FilterDTO()
            {
                SelectedPublishersName = new List <string>()
                {
                    "Publisher"
                }
            };
            var gamePipeline = new GamePipeline();

            gamePipeline.Register(new GameFilterByPublisher(filterDto.SelectedPublishersName));
            var gamesAfteFilter = gamePipeline.Process(_fakeGamesForFilter);

            Assert.Equal(_fakeGamesForFilter.Count, gamesAfteFilter.Count());
        }
コード例 #9
0
        public IEnumerable <GameDTO> GetGamesByFilter(FilterDTO filter, int page, PageSize pageSize, out int totalItemsByFilter)
        {
            var games = _unitOfWork.Games.GetAll();

            var filterGamePipeline = new GamePipeline();

            RegisterFilter(filterGamePipeline, filter, page, pageSize);

            var filterGames = filterGamePipeline.Process(games).ToList();

            var totalItemsByFilteripeline = new GamePipeline();

            RegisterFilter(totalItemsByFilteripeline, filter, 1, PageSize.All);
            totalItemsByFilter = totalItemsByFilteripeline.Process(games).Count();

            return(_mapper.Map <IEnumerable <GameDTO> >(filterGames));
        }
コード例 #10
0
        public void GetGamesByFilter_FilterByPageSizeAll_GetedGames()
        {
            var fakeGamesForFilter = new List <Game>()
            {
                new Game {
                    Id = Guid.NewGuid(), NameRu = "Игра1", Key = "Игра1"
                },
                new Game {
                    Id = Guid.NewGuid(), NameRu = "Игра2", Key = "Игра2"
                },
                new Game {
                    Id = Guid.NewGuid(), NameRu = "Игра3", Key = "Игра3"
                },
                new Game {
                    Id = Guid.NewGuid(), NameRu = "Игра4", Key = "Игра4"
                },
                new Game {
                    Id = Guid.NewGuid(), NameRu = "Игра5", Key = "Игра5"
                },
                new Game {
                    Id = Guid.NewGuid(), NameRu = "Игра6", Key = "Игра6"
                },
                new Game {
                    Id = Guid.NewGuid(), NameRu = "Игра7", Key = "Игра7"
                },
                new Game {
                    Id = Guid.NewGuid(), NameRu = "Игра8", Key = "Игра8"
                },
                new Game {
                    Id = Guid.NewGuid(), NameRu = "Игра9", Key = "Игра9"
                },
                new Game {
                    Id = Guid.NewGuid(), NameRu = "Игра10", Key = "Игра10"
                },
                new Game {
                    Id = Guid.NewGuid(), NameRu = "Игра11", Key = "Игра11"
                },
            };
            var gamePipeline = new GamePipeline();

            gamePipeline.Register(new GameFilterByPage(1, PageSize.All));
            var gamesAfteFilter = gamePipeline.Process(fakeGamesForFilter);

            Assert.True(gamesAfteFilter.ElementAt(10).NameRu == "Игра11");
        }