public void GetTaskType_Success_Test() { // Arrange int id = 1; R_TaskType taskType = SampleTaskType(id); // create mock for repository var mock = new Mock <ITaskTypeRepository>(); mock.Setup(s => s.GetTaskType(Moq.It.IsAny <int>())).Returns(taskType); // service TaskTypeService taskTypeService = new TaskTypeService(); TaskTypeService.Repository = mock.Object; // Act TaskTypeDTO result = taskTypeService.GetTaskType(id); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.TaskTypeId); }