Esempio n. 1
0
        public async Task <StandingViewModel> CreateAsync(Tournament tournament)
        {
            var standing = new Standing(tournament);
            await standing.RunMatchesAsync();

            await _repository.InsertOneAsync(standing);

            return(_mapper.Map <StandingViewModel>(standing));
        }
Esempio n. 2
0
        public async Task TestRunMatchesAsync()
        {
            // Arrange
            var tournament     = new TournamentBuilder().Build();
            var standing       = new Standing(tournament);
            var expectedScore0 = new List <string>()
            {
                "tt5164214", "tt7784604", "tt3778644"
            };
            var expectedScore1 = new List <string>()
            {
                "tt3501632", "tt4881806"
            };
            var expectedScore2 = new List <string>()
            {
                "tt3606756"
            };
            var expectedScore3 = new List <string>()
            {
                "tt4154756"
            };

            // Act
            await standing.RunMatchesAsync();

            // Assert
            standing.Rankings
            .Where(r => expectedScore0.Contains(r.Movie.Id))
            .ToList()
            .Should().HaveCount(expectedScore0.Count);

            standing.Rankings
            .Where(r => expectedScore1.Contains(r.Movie.Id))
            .ToList()
            .Should().HaveCount(expectedScore1.Count);

            standing.Rankings
            .Where(r => expectedScore2.Contains(r.Movie.Id))
            .ToList()
            .Should().HaveCount(expectedScore2.Count);

            standing.Rankings
            .Where(r => expectedScore3.Contains(r.Movie.Id))
            .ToList()
            .Should().HaveCount(expectedScore3.Count);
        }