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); }
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); }
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); }
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())); }