public async Task MatchRepository_CRD_Tests() { const int firstWarId = 1234; const int secondWarId = 5678; var sqlServerConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["WarDb"].ConnectionString; var repository = new MatchRepository(sqlServerConnectionString); var firstMatch = await CreateMatch(repository, firstWarId); var firstMatchWrongWarId = await repository.Get(secondWarId, firstMatch.Id); firstMatchWrongWarId.Should().BeNull(); var secondMatch = await CreateMatch(repository, firstWarId); var thirdMatch = await CreateMatch(repository, secondWarId); var firstWarCollection = await repository.GetAll(firstWarId); VerifyMatchInCollection(firstWarCollection, firstMatch); VerifyMatchInCollection(firstWarCollection, secondMatch); VerifyMatchNotInCollection(firstWarCollection, thirdMatch); var secondWarCollection = await repository.GetAll(secondWarId); VerifyMatchNotInCollection(secondWarCollection, firstMatch); VerifyMatchNotInCollection(secondWarCollection, secondMatch); VerifyMatchInCollection(secondWarCollection, thirdMatch); await VerifyMatchDelete(repository, firstWarId, firstMatch.Id); await VerifyMatchDelete(repository, firstWarId, secondMatch.Id); await VerifyMatchDelete(repository, secondWarId, thirdMatch.Id); }
private static async Task VerifyMatchDelete(MatchRepository repository, int warId, Guid matchId) { await repository.Delete(warId, matchId); var afterDelete = await repository.Get(warId, matchId); afterDelete.Should().BeNull(); }
private static async Task <Match> CreateMatch(MatchRepository repository, int warId) { var request = CreateTestMatch(); var id = await repository.Create(warId, request); var match = await repository.Get(warId, id); VerifyCreatedMatch(id, match, request); return(match); }