Ejemplo n.º 1
0
        public void TryToDeleteNotExistentDocument()
        {
            var personDocumentToDelete = IntegrationTestsUtils.CreateDocument("5", "Carlos3", "Carrero", "Johnson");

            var documentException =
                Assert.ThrowsAsync <DocumentException <Documents.Person> >(() => _commandCosmosDbRepository.DeleteDocumentAsync(personDocumentToDelete));

            Assert.IsTrue(documentException.Document == null);
        }
Ejemplo n.º 2
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");
        }
Ejemplo n.º 3
0
        public async Task AddDocument()
        {
            var personDocumentToAdd = IntegrationTestsUtils.CreateDocument("2", "Beatriz2", "Elena", "Saldarriaga");

            var cosmosDocumentResponse = await _commandCosmosDbRepository.AddDocumentAsync(personDocumentToAdd).ConfigureAwait(false);

            _documentsToDelete.Add(personDocumentToAdd);

            Assert.IsTrue(cosmosDocumentResponse.HttpStatusCode == HttpStatusCode.Created);
            Assert.IsTrue(cosmosDocumentResponse.RequestCharge > 0);
            Assert.IsTrue(cosmosDocumentResponse.Entities.FirstOrDefault()?.Id == "2");
            Assert.IsTrue(cosmosDocumentResponse.Entities.FirstOrDefault()?.FamilyName == "Saldarriaga");
            Assert.IsTrue(cosmosDocumentResponse.Entities.FirstOrDefault()?.FirstName == "Beatriz2");
            Assert.IsTrue(cosmosDocumentResponse.Entities.FirstOrDefault()?.MiddleName == "Elena");
        }