public async Task BoundaryTestFor_ValidDirectorNameLength() { //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 = true; //Act await userRepo.AddMovieManagement(_movieManagement); var result = await userRepo.SearchByMovieByIdAsync(_movieManagement.MovieId); var MinLength = 3; var MaxLength = 50; //Action var actualLength = _movieManagement.DirectedBy.Length; //Assert Assert.InRange(result.DirectedBy.Length, MinLength, MaxLength); Assert.InRange(actualLength, MinLength, MaxLength); //writing tset boolean output in text file, that is present in project directory if (actualLength == _movieManagement.DirectedBy.Length) { res = true; } File.AppendAllText("../../../../output_boundary_revised.txt", "BoundaryTestFor_ValidDirectorNameLength=" + res + "\n"); }