Пример #1
0
        public void IntegrationTest010()
        {
            // Arrange
            var documentCollection = this.GetDocumentCollection();
            IEnumerable <TechProductDocument> fetchedDocuments;
            var documentId    = Guid.NewGuid().ToString("N");
            var documentToAdd = new TechProductDocument
            {
                Id   = documentId,
                Name = "IntegrationTest009"
            };
            var update = documentCollection.Update();

            update.Add(documentToAdd);
            update.Commit();

            // Act
            update.Delete(documentId);
            update.Commit();

            // Assert
            documentCollection
            .Select()
            .Query(q => q.Id, documentId)
            .Execute()
            .Document(out fetchedDocuments);

            Assert.Equal(0, fetchedDocuments.Count());
        }
        public void IntegrationTest009()
        {
            // Arrange
            var documentCollection = this.GetDocumentCollection();

            var documentId    = Guid.NewGuid().ToString("N");
            var documentToAdd = new TechProductDocument
            {
                Id   = documentId,
                Name = "IntegrationTest009"
            };

            // Act
            documentCollection
            .Update()
            .Add(documentToAdd)
            .Execute();

            // Assert
            documentCollection
            .Select()
            .Filter(q => q.Id, documentId)
            .Execute()
            .Document(out var data);

            Assert.Single(data);
            Assert.Equal(documentId, data.ToList()[0].Id);
            Assert.Equal("IntegrationTest009", data.ToList()[0].Name);
        }
        public void IntegrationTest010()
        {
            // Arrange
            var documentCollection = this.GetDocumentCollection();

            var documentId1    = Guid.NewGuid().ToString("N");
            var documentId2    = Guid.NewGuid().ToString("N");
            var documentToAdd1 = new TechProductDocument
            {
                Id   = documentId1,
                Name = "Some value1"
            };
            var documentToAdd2 = new TechProductDocument
            {
                Id   = documentId2,
                Name = "Some value2"
            };

            documentCollection
            .Update()
            .Add(documentToAdd1)
            .Execute();

            documentCollection
            .Update()
            .Add(documentToAdd2)
            .Execute();

            // Act
            documentCollection
            .Update()
            .Delete(documentId1)
            .Execute();

            documentCollection
            .Update()
            .Delete(documentId2)
            .Execute();

            // Assert
            documentCollection
            .Select()
            .Query(q => q.Id, q => q.Any(documentId1, documentId2))
            .Execute()
            .Document(out var fetchedDocuments);

            Assert.Single(fetchedDocuments);
        }
        public void IntegrationTest013()
        {
            // Arrange
            var documentCollection = this.GetDocumentCollection();

            var documentId1    = Guid.NewGuid().ToString("N");
            var documentId2    = Guid.NewGuid().ToString("N");
            var documentToAdd1 = new TechProductDocument
            {
                Id   = documentId1,
                Name = "Some value1"
            };
            var documentToAdd2 = new TechProductDocument
            {
                Id   = documentId2,
                Name = "Some value2"
            };

            // Act
            documentCollection
            .Update()
            .Add(documentToAdd1)
            .Execute();

            documentCollection
            .Update()
            .Add(documentToAdd2)
            .Execute();

            // Assert
            documentCollection
            .Select()
            .Query(q => q.Id, q => q.Any(documentId1, documentId2))
            .Execute()
            .Document(out var fetchedDocuments);

            Assert.Equal(2, fetchedDocuments.Count());
            Assert.Contains(fetchedDocuments, q => q.Id.Equals(documentId1));
            Assert.Contains(fetchedDocuments, q => q.Id.Equals(documentId2));
            Assert.Contains(fetchedDocuments, q => q.Name.Equals(documentToAdd1.Name));
            Assert.Contains(fetchedDocuments, q => q.Name.Equals(documentToAdd2.Name));
        }
Пример #5
0
        public void IntegrationTest015()
        {
            // Arrange
            var documentCollection = this.GetDocumentCollection();
            IEnumerable <TechProductDocument> fetchedDocuments;
            var documentId1    = Guid.NewGuid().ToString("N");
            var documentId2    = Guid.NewGuid().ToString("N");
            var documentToAdd1 = new TechProductDocument
            {
                Id   = documentId1,
                Name = "IntegrationTest015"
            };
            var documentToAdd2 = new TechProductDocument
            {
                Id   = documentId2,
                Name = "IntegrationTest015"
            };
            var update = documentCollection.Update();

            // Act
            update.Add(documentToAdd1, documentToAdd2);
            update.Commit();

            // Assert
            documentCollection
            .Select()
            .Query(q => q.Id, $"({documentId1} OR {documentId2})")
            .Execute()
            .Document(out fetchedDocuments);

            Assert.Equal(2, fetchedDocuments.Count());
            Assert.True(fetchedDocuments.Any(q => q.Id.Equals(documentId1)));
            Assert.True(fetchedDocuments.Any(q => q.Id.Equals(documentId2)));
            Assert.True(fetchedDocuments.Any(q => q.Name.Equals("IntegrationTest015")));
            Assert.True(fetchedDocuments.Any(q => q.Name.Equals("IntegrationTest015")));
        }