public void CreateShouldDoIt() { // Arrange // Act var tournament = _factory.Create("name", 5); // Assert tournament.Name.ShouldBe("name"); tournament.Teams.Count.ShouldBe(5); tournament.Teams.All(x => x.Name.StartsWith("team")).ShouldBeTrue(); }
public async Task <Tournament> Handle(CreateTournamentRequest request, CancellationToken cancellationToken) { using (var context = _contextFactory.CreateContext()) using (var transaction = context.Database.BeginTransaction()) { var tournament = _tournamentFactory.Create(request.TournamentName, request.TeamsCount); var tournamentRepository = new DbRepository <Tournament>(context); await tournamentRepository.AddAsync(tournament); var rounds = _roundsService.CreateRoundsPerTournament(tournament); var roundRepository = new DbRepository <Round>(context); foreach (var round in rounds) { await roundRepository.AddAsync(round); } transaction.Commit(); return(tournament); } }