public void Test_For_Search_Projects(string searchText, bool exactMatch) { // Arrange var tasksList = new Models.ViewModels.Task[] { new Models.ViewModels.Task() { ProjectId = 1, ProjectName = "TestProject-1", TaskOwnerId = Guid.NewGuid(), Priority = 10, TaskId = 10, TaskName = "TestTask1" }, new Models.ViewModels.Task() { ProjectId = 2, ProjectName = "TestProject-2", TaskOwnerId = Guid.NewGuid(), Priority = 5, TaskId = 11, TaskName = "TestTask2" }, new Models.ViewModels.Task() { ProjectId = 3, ProjectName = "TestProject-3", TaskOwnerId = Guid.NewGuid(), Priority = 15, TaskId = 9, TaskName = "TestTask3" }, new Models.ViewModels.Task() { ProjectId = 4, ProjectName = "TestProject-4", TaskOwnerId = Guid.NewGuid(), Priority = 20, TaskId = 7, TaskName = "TestTask4" }, new Models.ViewModels.Task() { ProjectId = 5, ProjectName = "TestProject-5", TaskOwnerId = Guid.NewGuid(), Priority = 30, TaskId = 5, TaskName = "TestTask5", ParentTaskName = "TestParentTask1", ParentTaskId = 200 }, new Models.ViewModels.Task() { ProjectId = 5, ProjectName = "TestProject-5", TaskOwnerId = Guid.NewGuid(), Priority = 30, TaskId = 5, TaskName = "TestTask6", ParentTaskName = "TestParentTask1", ParentTaskId = 200 }, new Models.ViewModels.Task() { ProjectId = 5, ProjectName = "TestProject-5", TaskOwnerId = Guid.NewGuid(), Priority = 30, TaskId = 5, TaskName = "TestTask7", ParentTaskName = "TestParentTask2", ParentTaskId = 202 }, }.AsEnumerable(); IEnumerable <Models.ViewModels.Task> expectedResult; if (exactMatch) { expectedResult = tasksList.Where(p => p.ProjectName.ToLower().Equals(searchText.ToLower())); } else { expectedResult = tasksList; } mockTaskRepo.Setup(repo => repo.Search(It.IsAny <System.Linq.Expressions.Expression <Func <Models.DataModels.Task, bool> > >())).Returns(expectedResult.AsDataModel()); // Act var actualResult = tasksLogicTest.Search(searchText, exactMatch); // Assert Assert.NotNull(actualResult); Assert.Equal(expectedResult.Count(), actualResult.Count()); }