public async Task CreateClient_Returns_MongoClient()
        {
            // Arrange


            // Act
            var result = await _factory.CreateClient();

            // Assert
            Assert.IsInstanceOf <MongoClient>(result);
        }
Exemple #2
0
        public async Task MongoClientFactory_OnInsertOneAndFind_ShouldReturnInsertedDocument()
        {
            // Arrange
            var client     = _mongoClientFactory.CreateClient(_configuration.ConnectionString);
            var database   = client.GetDatabase(_configuration.DatabaseName);
            var collection = database.GetCollection <BsonDocument>("bar");

            // Act
            await collection.InsertOneAsync(new BsonDocument("name", "Jack"));

            var entities = await collection.Find(new BsonDocument("name", "Jack"))
                           .ToListAsync();

            // Assert
            entities.Should().NotBeNullOrEmpty();
            entities[0]["_id"].AsObjectId.Should().NotBeNull();
            entities[0]["name"].Should().Be("Jack");
        }
Exemple #3
0
        public void MongoClientFactoryCreateClient_ReturnValidClient()
        {
            // Arrange
            var configuration = new FakeConfiguration();
            var factory       = new MongoClientFactory();

            // Act
            var output = factory.CreateClient(configuration.ConnectionString);

            // Assert
            output.Should().NotBeNull();
        }