Exemple #1
0
        public async Task TryToAddExistentDocument()
        {
            var personDocumentAdded = await IntegrationTestsUtils
                                      .InsertDocumentAsync("1", "Beatriz1", "Elena", "Saldarriaga", _commandCosmosDbRepository, _documentsToDelete).ConfigureAwait(false);

            var documentException =
                Assert.ThrowsAsync <DocumentException <Documents.Person> >(() => _commandCosmosDbRepository.AddDocumentAsync(personDocumentAdded));

            Assert.IsTrue(documentException.Document != null);
        }
Exemple #2
0
        public async Task DeleteDocument()
        {
            var personDocumentAdded = await IntegrationTestsUtils
                                      .InsertDocumentAsync("6", "Beatriz3", "Elena", "Johnson", _commandCosmosDbRepository, _documentsToDelete, false)
                                      .ConfigureAwait(false);

            var cosmosDocumentResponse = await _commandCosmosDbRepository.DeleteDocumentAsync(personDocumentAdded).ConfigureAwait(false);

            Assert.IsTrue(cosmosDocumentResponse.HttpStatusCode == HttpStatusCode.NoContent);
            Assert.IsTrue(cosmosDocumentResponse.RequestCharge > 0);
            Assert.IsTrue(cosmosDocumentResponse.Entities.FirstOrDefault() == null);
        }
Exemple #3
0
        public async Task UpdateDocument()
        {
            var personDocumentAdded = await IntegrationTestsUtils
                                      .InsertDocumentAsync("4", "Chris", "Jerry", "Johnson", _commandCosmosDbRepository, _documentsToDelete).ConfigureAwait(false);

            var personDocumentToUpdate = IntegrationTestsUtils.CreateDocument(personDocumentAdded.DocumentId, "Carlos2", "Carrero", "Johnson");

            var cosmosDocumentResponse = await _commandCosmosDbRepository.UpdateDocumentAsync(personDocumentToUpdate).ConfigureAwait(false);

            Assert.IsTrue(cosmosDocumentResponse.HttpStatusCode == HttpStatusCode.OK);
            Assert.IsTrue(cosmosDocumentResponse.RequestCharge > 0);
            Assert.IsTrue(cosmosDocumentResponse.Entities.FirstOrDefault()?.FamilyName == "Johnson");
            Assert.IsTrue(cosmosDocumentResponse.Entities.FirstOrDefault()?.FirstName == "Carlos2");
            Assert.IsTrue(cosmosDocumentResponse.Entities.FirstOrDefault()?.MiddleName == "Carrero");
        }