public void MongoBookDBContext_GetCollection_ValidName_Success() { //Arrange var res = false; var settings = new Mongosettings() { Connection = "mongodb://localhost:27017", DatabaseName = "MovieMultiplex" }; _mockOptions.Setup(s => s.Value).Returns(settings); _mockClient.Setup(c => c.GetDatabase(_mockOptions.Object.Value.DatabaseName, null)).Returns(_mockDB.Object); //Act var context = new MongoDBContext(_mockOptions.Object); var myCollection = context.GetCollection <MovieManagement>("Movie"); if (context != null) { res = true; } //writing tset boolean output in text file, that is present in project directory File.AppendAllText("../../../../output_database_revised.txt", "MongoBookDBContext_GetCollection_ValidName_Success=" + res + "\n"); //Assert Assert.NotNull(myCollection); }
public void MongoDBContext_GetCollection_NameEmpty_Failure() { //Arrange var res = false; var settings = new Mongosettings() { Connection = "mongodb://*****:*****@127.0.0.1:27017/guestbook", DatabaseName = "FSEPABlogPost" }; _mockOptions.Setup(s => s.Value).Returns(settings); _mockClient.Setup(c => c .GetDatabase(_mockOptions.Object.Value.DatabaseName, null)) .Returns(_mockDB.Object); //Act var context = new MongoDBContext(_mockOptions.Object); var myCollection = context.GetCollection <BlogPost>(""); if (context != null) { res = true; } //writing tset boolean output in text file, that is present in project directory File.AppendAllText("../../../../output_database_revised.txt", "MongoDBContext_GetCollection_NameEmpty_Failure=" + res.ToString() + "\n"); //Assert Assert.Null(myCollection); }
public void MongoBookDBContext_Constructor_Success() { //Arrange var res = false; var settings = new Mongosettings() { Connection = "mongodb://*****:*****@127.0.0.1:27017/guestbook", DatabaseName = "guestbook" }; _mockOptions.Setup(s => s.Value).Returns(settings); _mockClient.Setup(c => c .GetDatabase(_mockOptions.Object.Value.DatabaseName, null)) .Returns(_mockDB.Object); //Act var context = new MongoDBContext(_mockOptions.Object); if (context != null) { res = true; } //writing tset boolean output in text file, that is present in project directory File.AppendAllText("../../../../output_database_revised.txt", "MongoBookDBContext_Constructor_Success=" + res + "\n"); //Assert Assert.IsType <MongoDBContext>(context); Assert.NotNull(context); }
public void MongoBookDBContext_Constructor_Success() { var settings = new Mongosettings() { Connection = "mongodb://test123 ", DatabaseName = "TestDB" }; _mockOptions.Setup(s => s.Value).Returns(settings); _mockClient.Setup(c => c .GetDatabase(_mockOptions.Object.Value.DatabaseName, null)) .Returns(_mockDB.Object); //Act var context = new MongoUserDBContext(_mockOptions.Object); //Assert Assert.NotNull(context); }
public void MongoBookDBContext_GetCollection_ValidName_Success() { //Arrange var settings = new Mongosettings() { Connection = "mongodb://tes123 ", DatabaseName = "TestDB" }; _mockOptions.Setup(s => s.Value).Returns(settings); _mockClient.Setup(c => c.GetDatabase(_mockOptions.Object.Value.DatabaseName, null)).Returns(_mockDB.Object); //Act var context = new MongoUserDBContext(_mockOptions.Object); var myCollection = context.GetCollection <User>("User"); //Assert Assert.NotNull(myCollection); }