public void Given_GoalDoesNotExist_When_GetTeamLeagueMatchGoal_Then_GoalNotFoundExceptionIsThrown()
        {
            // Arrange
            var teams  = new TeamsBuilder().Build();
            var league = new TeamLeagueBuilder()
                         .WithCompetitors(teams)
                         .WithRounds()
                         .WithGoals()
                         .Build();

            var leagues    = Enumerable.Repeat(league, 1);
            var matchGuid  = new Guid("00000000-0000-0000-0000-000000000000");
            var match      = league.GetMatch(matchGuid);
            var matchEntry = match.MatchEntries.SingleOrDefault(me => me.Team.Name == "Tottenham Hotspur");
            var goalGuid   = matchEntry.Goals.ToList()[0].Guid;

            var contextMock = MockDbContext(leagues.AsQueryable());
            var loggerMock  = new Mock <ILogger <GetTeamLeagueMatchGoalQueryHandler> >();
            var handler     = new GetTeamLeagueMatchGoalQueryHandler(
                contextMock.Object,
                Mapper.MapperConfig(),
                loggerMock.Object
                );

            // Act
            var request = new GetTeamLeagueMatchGoalQuery
            {
                LeagueName = "Premier League",
                MatchGuid  = matchGuid,
                GoalGuid   = new Guid("00000000-0000-0000-0000-000000000000")
            };
            Func <Task> func = async() => await handler.Handle(request, CancellationToken.None);

            // Assert
            func.Should().Throw <GoalNotFoundException>();
        }
示例#2
0
        public async Task <Application.TeamLeagueMatches.Queries.GetTeamLeagueMatchGoal.GoalDto> GetTeamLeagueMatchGoal(GetTeamLeagueMatchGoalQuery query)
        {
            var response = await httpRequestFactory.Get($"{teamLeagueApiUrl}/{query.LeagueName}/matches/{query.MatchGuid}/goals/{query.GoalGuid}");

            if (response.IsSuccessStatusCode)
            {
                return(response.ContentAsType <Application.TeamLeagueMatches.Queries.GetTeamLeagueMatchGoal.GoalDto>());
            }
            return(null);
        }