public async Task TestFor_SearchByAllotMovieIdAsync() { //Arrange //mocking //mocking var res = false; _mockCollection.Setup(op => op.InsertOneAsync(_movieManagement, null, default(CancellationToken))).Returns(Task.CompletedTask); _mockContext.Setup(c => c.GetCollection <MovieManagement>(typeof(MovieManagement).Name)).Returns(_mockCollection.Object); _mockOptions.Setup(s => s.Value).Returns(settings); var context = new MongoDBContext(_mockOptions.Object); var userRepo = new MovieServices(context); //Action var movie = await userRepo.RegisterAsync(_movieManagement); //Assert Assert.NotNull(movie); Assert.Equal(_movieManagement.DirectedBy, movie.DirectedBy); //writing tset boolean output in text file, that is present in project directory if (movie != null) { res = true; } File.AppendAllText("../../../../output_revised.txt", "TestFor_SearchByAllotMovieIdAsync=" + res + "\n"); }
public async Task BoundaryTestFor_ValidMovieName() { //mocking _mockCollection.Setup(op => op.InsertOneAsync(_movieManagement, null, default(CancellationToken))).Returns(Task.CompletedTask); _mockContext.Setup(c => c.GetCollection <MovieManagement>(typeof(MovieManagement).Name)).Returns(_mockCollection.Object); //Craetion of new Db _mockOptions.Setup(s => s.Value).Returns(settings); var context = new MongoDBContext(_mockOptions.Object); var userRepo = new MovieServices(context); //Act await userRepo.RegisterAsync(_movieManagement); var result = await userRepo.SearchByMovieByIdAsync(_movieManagement.MovieId); bool DirectorName = Regex.IsMatch(result.DirectedBy, @"^[a-zA-Z0-9]{4,10}$", RegexOptions.IgnoreCase); bool isUserName = Regex.IsMatch(_movieManagement.DirectedBy, @"^[a-zA-Z0-9]{4,10}$", RegexOptions.IgnoreCase); //writing tset boolean output in text file, that is present in project directory File.AppendAllText("../../../../output_boundary_revised.txt", "BoundaryTestFor_ValidBuyerName=" + isUserName.ToString() + "\n"); //Assert Assert.True(isUserName); Assert.True(DirectorName); }
public async Task BoundaryTestFor_ValidMovieId() { //mocking _mockCollection.Setup(op => op.InsertOneAsync(_movieManagement, null, default(CancellationToken))).Returns(Task.CompletedTask); _mockContext.Setup(c => c.GetCollection <MovieManagement>(typeof(MovieManagement).Name)).Returns(_mockCollection.Object); //Craetion of new Db _mockOptions.Setup(s => s.Value).Returns(settings); var context = new MongoDBContext(_mockOptions.Object); var userRepo = new MovieServices(context); var res = false; //Act await userRepo.RegisterAsync(_movieManagement); var result = await userRepo.SearchByMovieByIdAsync(_movieManagement.MovieId); Assert.InRange(_movieManagement.MovieId.Length, 20, 30); //writing tset boolean output in text file, that is present in project directory if (result.MovieId.Length.ToString() == _movieManagement.MovieId.Length.ToString()) { res = true; } File.AppendAllText("../../../../output_boundary_revised.txt", "BoundaryTestFor_ValidMovieId=" + res + "\n"); }
public async void CreateNewMovie_Null_Failure() { // Arrange _movieManagement = null; var res = true; //Act var bookRepo = new MovieServices(_mockContext.Object); // Assert var create = bookRepo.RegisterAsync(_movieManagement); await Assert.ThrowsAsync <ArgumentNullException>(() => create); if (create.IsCompletedSuccessfully) { res = false; } //writing tset boolean output in text file, that is present in project directory File.AppendAllText("../../../../output_exception_revised.txt", "CreateNewBuyer_Null_Failure=" + res + "\n"); }