public void MongoDBGetCollection_ShouldFail_CollectionNameNotSupplied() { //Arrange _mockClient.Setup(c => c .GetDatabase(_mockOptions.Object.Value.DatabaseName, null)) .Returns(_mockDB.Object); //Act var context = new MongoPhoneBookDBContext(_mockOptions.Object); var myCollection = context.GetCollection <PhoneBook>(); //Assert Assert.Null(myCollection); }
public void MongoDBGetCollection_ShouldReturn_ValidCollection() { //Arrange var settings = new MongoDBSettings() { ConnectionString = "mongodb://tes123 ", DatabaseName = "TestDB", PhoneBooksCollectionName = "123" }; _mockOptions.Setup(s => s.Value).Returns(settings); _mockClient.Setup(c => c.GetDatabase(_mockOptions.Object.Value.DatabaseName, null)).Returns(_mockDB.Object); //Act var context = new MongoPhoneBookDBContext(_mockOptions.Object); var myCollection = context.GetCollection <PhoneBook>(); //Assert Assert.NotNull(myCollection); }