public async Task ByIdShouldReturnTournamentByGivenId() { //Arrange const string databaseName = "TournamentById"; ITournamentService service = await GetTournamentService(databaseName); //Act var expectedTournamentId = 1; var actualTournament = service.ById(expectedTournamentId); //Assert Assert.True(expectedTournamentId == actualTournament.Id); }
public async Task DeleteShouldRemoveTournamentById() { //Arrange const string databaseName = "TournamentDelete"; ITournamentService service = await GetTournamentService(databaseName); //Act var tournamentId = 1; await service.Delete(tournamentId); var tournament = service.ById(tournamentId); //Assert Assert.True(tournament == null); }
public async Task StartShouldCreateMatchesAndSetIsStartedTrue() { const string databaseName = "TournamentStart"; ITournamentService service = await GetTournamentService(databaseName); //Act var tournamentId = 4; var expectedTournament = service.ById(tournamentId); service.Start(tournamentId); var db = new FakeSportDbContext(databaseName); var actualTournament = db.Data.Tournaments .FirstOrDefault(t => t.Id == tournamentId); //Assert Assert.True(actualTournament.IsStarted); }
public async Task EditShouldReturnTournamentNotfound() { //Arrange const string databaseName = "TournamentEditNotfound"; ITournamentService service = await GetTournamentService(databaseName); //Act int tournamentId = -1; TournamentFormModel expectedTournament = new TournamentFormModel() { Id = tournamentId, Name = "SofiaOpen", Place = "Sofia" }; await service.Edit(expectedTournament); var actualTournament = service.ById(tournamentId); //Assert Assert.True(actualTournament == null); }
public async Task EditShouldEditTournamentByModel() { //Arrange const string databaseName = "TournamentEdit"; ITournamentService service = await GetTournamentService(databaseName); //Act int tournamentId = 1; TournamentFormModel expectedTournament = new TournamentFormModel() { Id = tournamentId, Name = "SofiaOpen", Place = "Sofia" }; await service.Edit(expectedTournament); var actualTournament = service.ById(tournamentId); //Assert Assert.Equal(expectedTournament.Name, actualTournament.Name); Assert.Equal(expectedTournament.Place, actualTournament.Place); }