public async void RemovePolicyDocument() { _logger.LogInformation("AddPolicyDocument..."); var policyId = _policiesFixture.Items.First().PolicyId; Document insertedDocument; using (var dbTransaction = await _dbConnectionFactory.BeginUserTransactionAsync(_userId)) { var newItem = new Document() { Name = $"REPOSITORY_TEST_{DateTime.Now:yyyyMMddHHmmssfff}.jpg", Type = "jpg", Data = await File.ReadAllBytesAsync("./TestFiles/Test.jpg") }; insertedDocument = await _repository.InsertDocumentAsync(dbTransaction, newItem); await _repository.AddPolicyDocument(dbTransaction, policyId, insertedDocument.DocumentId); dbTransaction.Commit(); } using (var dbConnection = await _dbConnectionFactory.OpenUserConnectionAsync(_userId)) { var result = await _repository.GetPolicyDocumentsAsync(dbConnection, policyId); Assert.NotNull(result); Assert.Contains(result, candidate => candidate.DocumentId == insertedDocument.DocumentId); } using (var dbTransaction = await _dbConnectionFactory.BeginUserTransactionAsync(_userId)) { await _repository.RemovePolicyDocument(dbTransaction, policyId, insertedDocument.DocumentId); dbTransaction.Commit(); } using (var dbConnection = await _dbConnectionFactory.OpenUserConnectionAsync(_userId)) { var result = await _repository.GetPolicyDocumentsAsync(dbConnection, policyId); Assert.NotNull(result); Assert.DoesNotContain(result, candidate => candidate.DocumentId == insertedDocument.DocumentId); } }