public async void Given_MatchHasSubstitutions_When_GetTeamLeagueMatchDetails_Then_ReturnMatchWithSubstitutions() { // Arrange var teams = new TeamsBuilder().Build(); var league = new TeamLeagueBuilder() .WithCompetitors(teams) .WithRounds() .WithSubstitutions() .Build(); var leagues = Enumerable.Repeat(league, 1); var contextMock = MockDbContext(leagues.AsQueryable()); var handler = new GetTeamLeagueMatchDetailsQueryHandler( contextMock.Object ); //Act var guid = new Guid("00000000-0000-0000-0000-000000000000"); var request = new GetTeamLeagueMatchDetailsQuery { LeagueName = "Premier League", Guid = guid }; var result = await handler.Handle(request, CancellationToken.None); //Assert result.Should().NotBeNull(); result.Guid.Should().Be(guid); result.MatchEntries[0].Substitutions.Should().NotBeNull(); result.MatchEntries[0].Substitutions.Count().Should().Be(2); result.MatchEntries[1].Substitutions.Should().NotBeNull(); result.MatchEntries[1].Substitutions.Count().Should().Be(2); }
public async void Given_MatchDoesNotExist_When_GetTeamLeagueMatchDetails_Then_ReturnNull() { // Arrange var teams = new TeamsBuilder().Build(); var league = new TeamLeagueBuilder() .WithCompetitors(teams) .WithRounds() .Build(); var leagues = Enumerable.Repeat(league, 1); var contextMock = MockDbContext(leagues.AsQueryable()); var handler = new GetTeamLeagueMatchDetailsQueryHandler( contextMock.Object ); //Act var request = new GetTeamLeagueMatchDetailsQuery { LeagueName = "Premier League", Guid = new Guid("00000000-0000-0000-0000-000000000001") }; var result = await handler.Handle(request, CancellationToken.None); //Assert result.Should().BeNull(); }
public async void Given_MatchDoesExist_When_GetTeamLeagueMatchDetails_Then_ReturnMatch() { // Arrange var teams = new TeamsBuilder().Build(); var league = new TeamLeagueBuilder() .WithCompetitors(teams) .WithRounds() .Build(); var leagues = Enumerable.Repeat(league, 1); var contextMock = MockDbContext(leagues.AsQueryable()); var handler = new GetTeamLeagueMatchDetailsQueryHandler( contextMock.Object ); //Act var guid = new Guid("00000000-0000-0000-0000-000000000000"); var request = new GetTeamLeagueMatchDetailsQuery { LeagueName = "Premier League", Guid = guid }; var result = await handler.Handle(request, CancellationToken.None); //Assert result.Should().NotBeNull(); result.Guid.Should().Be(guid); result.RoundName.Should().Be("Round 1"); result.Home().Should().NotBeNull(); result.Away().Should().NotBeNull(); //Assert lineup result.MatchEntries[0].Lineup.Count.Should().Be(11); int number = 1; result.MatchEntries[0].Lineup.ForEach(l => { l.PlayerNumber.Should().Be(number.ToString()); l.TeamMatchEntryTeamName.Should().Be("Tottenham Hotspur"); number++; }); result.MatchEntries[1].Lineup.Count.Should().Be(11); number = 1; result.MatchEntries[1].Lineup.ForEach(l => { l.PlayerNumber.Should().Be(number.ToString()); l.TeamMatchEntryTeamName.Should().Be("Manchester City"); number++; }); }
public async Task <Application.TeamLeagueMatches.Queries.GetTeamLeagueMatchDetails.TeamMatchDto> GetTeamLeagueMatchDetails(GetTeamLeagueMatchDetailsQuery query) { var response = await httpRequestFactory.Get($"{teamLeagueApiUrl}/{query.LeagueName}/matches/{query.Guid}/details"); if (response.IsSuccessStatusCode) { var settings = new JsonSerializerSettings { Converters = { new JsonInterfaceConverter <Application.TeamLeagueMatches.Queries.GetTeamLeagueMatchDetails.TeamMatchEntryDto, ITeamMatchEntryWithDetailsDto>(), new JsonInterfaceConverter <Application.TeamLeagueMatches.Queries.GetTeamLeagueMatchDetails.TeamMatchDto, ITeamMatchDto <ITeamMatchEntryWithDetailsDto> >(), new JsonInterfaceConverter <Application.TeamLeagueMatches.Queries.GetTeamLeagueMatchDetails.TeamDto, ITeamDto>(), new JsonInterfaceConverter <Application.TeamLeagueMatches.Queries.GetTeamLeagueMatchDetails.IntegerScoreDto, IIntegerScoreDto>(), new JsonInterfaceConverter <Application.TeamLeagueMatches.Queries.GetTeamLeagueMatchDetails.LineupEntryDto, ILineupEntryDto>(), new JsonInterfaceConverter <Application.TeamLeagueMatches.Queries.GetTeamLeagueMatchDetails.PlayerDto, IPlayerDto>(), new JsonInterfaceConverter <Application.TeamLeagueMatches.Queries.GetTeamLeagueMatchDetails.GoalDto, IGoalDto>(), new JsonInterfaceConverter <Application.TeamLeagueMatches.Queries.GetTeamLeagueMatchDetails.SubstitutionDto, ISubstitutionDto>() } }; return(response.ContentAsType <Application.TeamLeagueMatches.Queries.GetTeamLeagueMatchDetails.TeamMatchDto>(settings)); } return(null); }