Ejemplo n.º 1
0
        public async Task Handler_Returns_Next_Page_Of_Games()
        {
            var expectedGame = _fixture
                               .Build <GameRecord>()
                               .With(game => game.Title, "Dark Souls 3")
                               .With(game => game.User, _testQuery.User)
                               .With(game => game.UserId, _testQuery.User.Id)
                               .Create();

            var unexpectedGame = _fixture
                                 .Build <GameRecord>()
                                 .With(game => game.Title, "Bloodborne")
                                 .With(game => game.User, _testQuery.User)
                                 .With(game => game.UserId, _testQuery.User.Id)
                                 .Create();

            await _context.GameRecords.AddAsync(unexpectedGame);

            await _context.GameRecords.AddAsync(expectedGame);

            await _context.SaveChangesAsync();

            var query = new GameListGetQuery(
                1,
                1,
                _testQuery.SearchQuery,
                _testQuery.User);

            var result = await _handler.Handle(query);

            result.Games.First().Title.Should().Be(expectedGame.Title);
        }
Ejemplo n.º 2
0
        public void Query_Sets_Default_Item_Count_For_Zero(string searchQuery)
        {
            var query = new GameListGetQuery(0, 1, searchQuery,
                                             _testUser);

            query.ItemCount.Should().BePositive();
        }
Ejemplo n.º 3
0
        public GameListGetQueryHandlerTests()
        {
            _fixture = new Fixture();
            _fixture.Behaviors.Add(new OmitOnRecursionBehavior());

            _context = InitializeDatabase();

            _testQuery = new GameListGetQuery(
                5,
                0,
                string.Empty,
                _fixture.Create <ApplicationUser>());

            _gameRecords = _fixture
                           .Build <GameRecord>()
                           .With(game => game.User, _testQuery.User)
                           .With(game => game.UserId, _testQuery.User.Id)
                           .CreateMany();

            _testRecord = _fixture
                          .Build <GameRecord>()
                          .With(game => game.User, _testQuery.User)
                          .With(game => game.UserId, _testQuery.User.Id)
                          .Create();

            _handler = new GameListGetQueryHandler(_context);
        }
Ejemplo n.º 4
0
        public async Task Handler_Returns_Total_Count()
        {
            await InitializeRecords();

            var count = await _context.Games.CountAsync();

            var query = new GameListGetQuery(10, 0, _testQuery.SearchQuery,
                                             null);

            var result = await _handler.Handle(query);

            result.TotalCount.Should().Be(count);
        }
Ejemplo n.º 5
0
        public async Task Handler_Returns_Requested_Count()
        {
            await _context.GameRecords.AddAsync(_testRecord);

            await InitializeRecords();

            var request = new GameListGetQuery(1, 0, _testQuery.SearchQuery,
                                               _testQuery.User);

            var result = await _handler.Handle(request);

            result.Games.Should().HaveCount(1);
        }
Ejemplo n.º 6
0
        public async Task Handler_Returns_Records_When_Search_Query_Is_Empty()
        {
            await _context.GameRecords.AddAsync(_testRecord);

            await InitializeRecords();

            var request = new GameListGetQuery(1, 0, string.Empty,
                                               _testQuery.User);

            var result = await _handler.Handle(request);

            result.Games.Should().NotBeEmpty();
        }
Ejemplo n.º 7
0
        public async Task Handler_Returns_Record_With_Search_Query_For_Title()
        {
            var record = _fixture
                         .Build <GameRecord>()
                         .With(g => g.Title, "Nioh")
                         .Create();

            await _context.GameRecords.AddAsync(record);

            await InitializeRecords();

            var request = new GameListGetQuery(1, 0, record.Title,
                                               null);

            var result = await _handler.Handle(request);

            result.Games.Should().Contain(g => g.Title == record.Title);
            result.TotalCount.Should().Be(request.ItemCount);
        }