示例#1
0
        public void Winner_Three_Round()
        {
            // Arrange
            var players     = _fixture.GetMovies();
            var competition = new Competition(Guid.NewGuid(), 8);

            competition.AddPlayers(players);

            // Act
            competition.Start();
            var winners = competition.GetBracketByRound(3).GetWinners();

            // Assert
            Assert.Equal("Vingadores: Guerra Infinita", winners[0].Title);
        }
示例#2
0
        public void Classification_Last_Round()
        {
            // Arrange
            var players     = _fixture.GetMovies();
            var competition = new Competition(Guid.NewGuid(), 8);

            competition.AddPlayers(players);

            // Act
            competition.Start();
            var ranking = competition.GetBracketByRound(3).Ranking.ToList();

            // Assert
            Assert.Equal("Vingadores: Guerra Infinita", ranking[0].Title);
            Assert.Equal("Os Incríveis 2", ranking[1].Title);
        }
示例#3
0
        public void Winner_First_Round()
        {
            // Arrange
            var players     = _fixture.GetMovies();
            var competition = new Competition(Guid.NewGuid(), 8);

            competition.AddPlayers(players);

            // Act
            competition.Start();
            var winners = competition.GetBracketByRound(1).GetWinners();

            // Assert
            Assert.Equal("Vingadores: Guerra Infinita", winners[0].Title);
            Assert.Equal("Thor: Ragnarok", winners[1].Title);
            Assert.Equal("Os Incríveis 2", winners[2].Title);
            Assert.Equal("Jurassic World: Reino Ameaçado", winners[3].Title);
        }
示例#4
0
        public async Task <ICommandResult> Handler(NewCompetitionCommand command)
        {
            var movies = await _movieRepository.GetByIdsAsync(command.PlayerIds);

            var competition = new Competition(Guid.NewGuid(), command.NumberOfPlayers);

            competition.AddPlayers(movies.ToList());

            var validator      = new CompetitionValidator();
            var validateResult = validator.Validate(competition);

            if (!validateResult.IsValid)
            {
                return(new ValidationFailureEvent(validateResult.Errors));
            }

            competition.Start();
            var ranking = competition.GetBracketByRound(competition.NumberOfRounds).Ranking;

            return(new CompetitionCompletedEvent(ranking.ToList()));
        }