public async Task LeagueQueryPlayerInternalIdsFilterAndLeaguesFilterShouldReturnValidData() { var command = new LeaguesQuery { LeagueId = new[] { _testDbFixture.MockedDataInstance.LeagueForJoinId1, _testDbFixture.MockedDataInstance.LeagueForJoinId2, }, Pid = new [] { _testDbFixture.MockedDataInstance.Player1, _testDbFixture.MockedDataInstance.Player3, _testDbFixture.MockedDataInstance.Player5, } }; var playersService = Substitute.For <IPlayersService>(); await using (var context = _testDbFixture.LeaguesContextFactory.Create()) { var uow = new UnitOfWork <LeaguesContext>(context); var commandHandler = new LeaguesQueryHandler(uow, _mapper, playersService); List <LeagueDto> result = (await commandHandler.Handle(command, CancellationToken.None)).Items.ToList(); const int expectedLeaguesCount = 2; result.Count.Should().Be(expectedLeaguesCount); List <PlayerWithLeagueStatusDto> playerWithLeagueStatuses = result.SelectMany(l => l.PlayersLeagueStatuses).ToList(); const int player1ExistsInLeaguesCount = 4; playerWithLeagueStatuses.Count.Should().Be(player1ExistsInLeaguesCount); } }
public async Task LeagueQueryWithExternalIdOnlyShouldReturnValidData() { var command = new LeaguesQuery { PlayerExternalId = Guid.NewGuid().ToString(), }; var retDto = new PlayerInternalIdDto { InternalId = _testDbFixture.MockedDataInstance.Player1 }; var playersService = Substitute.For <IPlayersService>(); playersService.GetInternalIdAsync(command.PlayerExternalId).ReturnsForAnyArgs(retDto); await using (var context = _testDbFixture.LeaguesContextFactory.Create()) { var uow = new UnitOfWork <LeaguesContext>(context); var commandHandler = new LeaguesQueryHandler(uow, _mapper, playersService); List <LeagueDto> result = (await commandHandler.Handle(command, CancellationToken.None)).Items.ToList(); result.Count.Should().Be(context.Leagues.Count()); List <PlayerWithLeagueStatusDto> playerWithLeagueStatuses = result.SelectMany(l => l.PlayersLeagueStatuses).ToList(); const int player1ExistsInLeaguesCount = 2; playerWithLeagueStatuses.Count.Should().Be(player1ExistsInLeaguesCount); } }
public async Task LeagueQueryLeaguesFilterShouldReturnValidData() { var command = new LeaguesQuery { LeagueId = new[] { _testDbFixture.MockedDataInstance.LeagueForJoinId1, _testDbFixture.MockedDataInstance.LeagueForJoinId2, } }; var playersService = Substitute.For <IPlayersService>(); await using (var context = _testDbFixture.LeaguesContextFactory.Create()) { var uow = new UnitOfWork <LeaguesContext>(context); var commandHandler = new LeaguesQueryHandler(uow, _mapper, playersService); List <LeagueDto> result = (await commandHandler.Handle(command, CancellationToken.None)).Items.ToList(); const int expectedLeaguesCount = 2; result.Count.Should().Be(expectedLeaguesCount); } }