Esempio 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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public async Task SetupAsync()
        {
            _cosmosDbConfiguration = new CosmosDbConfiguration("https://localhost:8081",
                                                               "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==", "People", "PeopleCollection");

            _mapper = MappingConfiguration.Configure(new MappingProfile());

            _queryCosmosDbRepository = new QueryCosmosDbRepository <Entities.Person, Person>(_cosmosDbConfiguration, _mapper);

            _querySameEntityAndDocumentCosmosDbRepository = new QueryCosmosDbRepository <Entities.Person, Entities.Person>(_cosmosDbConfiguration, _mapper);

            _peopleListToTest = await IntegrationTestsUtils.AddDocumentListToTestAsync(_cosmosDbConfiguration, _mapper).ConfigureAwait(false);
        }
Esempio n. 5
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");
        }
Esempio n. 6
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");
        }
Esempio n. 7
0
 public Task TearDownAsync() =>
 IntegrationTestsUtils.DeleteDocumentByIdAndPartitionKeyToTestAsync(_commandCosmosDbRepository, _documentsToDelete);
Esempio n. 8
0
 public Task TearDownAsync() => IntegrationTestsUtils.DeleteDocumentListToTestAsync(_cosmosDbConfiguration, _peopleListToTest, _mapper);