public void ReadById_ShouldMatchReadByIdInRepository_Once() { //arrange var AssigneeRepositoryMock = new Mock <IAssigneeRepository>(); IAssigneeService service = new AssigneeService(AssigneeRepositoryMock.Object); //assign AssigneeRepositoryMock.Setup(r => r.ReadById(50)); service.ReadById(50); //assert AssigneeRepositoryMock.Verify(r => r.ReadById(50), Times.Once()); CheckPerformance(() => service.ReadById(50), 1000); }
public void ReadById_withNegativeId_ShouldThrowExeption_Once() { //arrange var assigneeRepositoryMock = new Mock <IAssigneeRepository>(); IAssigneeService service = new AssigneeService(assigneeRepositoryMock.Object); Assignee mockAssignee = new Assignee() { Id = -1 }; //assign assigneeRepositoryMock.Setup(rm => rm.ReadById(-1)); service.ReadById(-1); //assert assigneeRepositoryMock.Verify(rm => rm.ReadById(-1), Times.Once); }