Exemplo n.º 1
0
        public async Task DeleteDocument_DocumentExists_DocumentIsDeleted()
        {
            // Arrange
            var db         = new MongoDb(ConnectionString, DatabaseId);
            var documentId = Guid.NewGuid().ToString();
            var person     = new PersonTest
            {
                PersonId = Guid.NewGuid(),
                Name     = "Barney Rubble",
                Age      = 87
            };
            var personEnvelope = new DocumentBase <PersonTest>()
            {
                VM = person
            };
            await db.UpsertDocument(CollectionId, documentId, personEnvelope);

            // Act
            await db.DeleteDocument(CollectionId, documentId);

            var exists = db.DocumentExists(CollectionId, documentId);

            // Assert
            exists.Should().BeFalse();
        }
Exemplo n.º 2
0
        public async Task DeleteDocument_DocumentNotExists_NoExceptionThrown()
        {
            // Arrange
            var db         = new MongoDb(ConnectionString, DatabaseId);
            var documentId = Guid.NewGuid().ToString();

            // Act
            var exception = await Record.ExceptionAsync(() => db.DeleteDocument(CollectionId, documentId));

            // Assert
            exception.Should().BeNull();
        }
Exemplo n.º 3
0
        public async Task DeleteDocument_DocumentIdIsNull_ThrowsException(string documentId)
        {
            // Arrange
            var db = new MongoDb(ConnectionString, DatabaseId);

            // Act
            var exception = await Record.ExceptionAsync(() => db.DeleteDocument(CollectionId, documentId));

            // Assert
            exception.Should().NotBeNull();
            exception.Should().BeOfType <ArgumentNullException>();
        }