public async void Given_TeamLeagueExist_When_GetTeamLeagueTable_Then_ReturnTable()
        {
            // Arrange
            var sports = new TeamSports
            {
                Options = new TeamSportsOptions
                {
                    AmountOfPlayers = 11
                }
            };
            var teams  = new TeamsBuilder().Build();
            var league = new TeamLeagueBuilder()
                         .WithCompetitors(teams)
                         .Build();

            league.Sports = sports;
            league.CreateRounds();

            var scores = new List <Tuple <Tuple <Team, int>, Tuple <Team, int> > >
            {
                AddScore(teams[0], teams[1], 1, 0),
                AddScore(teams[2], teams[3], 1, 1),
                AddScore(teams[0], teams[2], 2, 1),
                AddScore(teams[3], teams[1], 0, 1)
            };

            SetScores(league, scores);

            var contextMock = MockDbContext(new TeamLeague[] { league }.AsQueryable());
            var handler     = new GetTeamLeagueTableQueryHandler(
                contextMock.Object, Mapper.CreateMapper());

            //Act
            var result = await handler.Handle(new GetTeamLeagueTableQuery { LeagueName = "Premier League" }, CancellationToken.None);

            //Assert
            result.Should().NotBeNull();
            result.Table.Items.Should().NotBeNull();
            result.Table.Items.Count.Should().Be(4);
            result.Table.Items[0].Position.Should().Be(1);
            result.Table.Items[0].GamesPlayed.Should().Be(2);
            result.Table.Items[0].GamesWon.Should().Be(2);
            result.Table.Items[0].GamesDrawn.Should().Be(0);
            result.Table.Items[0].GamesLost.Should().Be(0);
            result.Table.Items[0].GoalsFor.Should().Be(3);
            result.Table.Items[0].GoalsAgainst.Should().Be(1);
            result.Table.Items[0].GoalDifference.Should().Be(2);
            result.Table.Items[0].Points.Should().Be(6);
        }
Exemplo n.º 2
0
        public void Given_TeamsAreAdded_When_CreateRounds_Then_CreateAllRounds()
        {
            //Arrange
            var sports = new TeamSports {
                Options = new TeamSportsOptions {
                    AmountOfPlayers = 11
                }
            };
            var league = new TeamLeagueBuilder()
                         .WithSports(sports)
                         .WithCompetitors(new TeamsBuilder().Build())
                         .Build();

            //Act
            league.CreateRounds();

            //Assert
            league.Rounds.Count.Should().Be(6);
            league.Rounds.ForEach(r =>
                                  r.Matches.Count.Should().Be(2)
                                  );
        }