public void GetTaskTypesPaged_Success_Test() { // Arrange string searchTerm = ""; int pageIndex = 0; int pageSize = 10; // list IList <R_TaskType> list = new List <R_TaskType>(); for (int i = 1; i <= pageSize; i++) { list.Add(SampleTaskType(i)); } // create mock for repository var mock = new Mock <ITaskTypeRepository>(); mock.Setup(s => s.GetTaskTypes(Moq.It.IsAny <string>(), Moq.It.IsAny <int>(), Moq.It.IsAny <int>())).Returns(list); // service TaskTypeService taskTypeService = new TaskTypeService(); TaskTypeService.Repository = mock.Object; // Act var resultList = taskTypeService.GetTaskTypes(searchTerm, pageIndex, pageSize); TaskTypeDTO result = resultList.FirstOrDefault(); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.TaskTypeId); Assert.AreEqual(10, resultList.Count); }
public void GetTaskTypes_Success_Test() { // Arrange R_TaskType taskType = SampleTaskType(1); IList <R_TaskType> list = new List <R_TaskType>(); list.Add(taskType); // create mock for repository var mock = new Mock <ITaskTypeRepository>(); mock.Setup(s => s.GetTaskTypes()).Returns(list); // service TaskTypeService taskTypeService = new TaskTypeService(); TaskTypeService.Repository = mock.Object; // Act var resultList = taskTypeService.GetTaskTypes(); TaskTypeDTO result = resultList.FirstOrDefault(); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.TaskTypeId); }