public ServiceExecutionResultWithModel <Models.Todo> Find(int id) { if (!existTodoRepository.Exist(id)) { return(ServiceExecutionResultWithModel <Models.Todo> .WitError()); } var todo = findByTodoIdRepository.Find(id); return(ServiceExecutionResultWithModel <Models.Todo> .With(todo)); }
public void return_not_found_when_is_not_found() { const int someTodoId = 2; var service = new Mock <IFindByTodoIdService>(); service .Setup(x => x.Find(someTodoId)) .Returns(ServiceExecutionResultWithModel <TuduManayer.Domain.Todo.FindById.Models.Todo> .WitError()); var controller = new FindByTodoIdController(service.Object); var response = controller.Find(someTodoId) as NotFoundResult; response.StatusCode.ShouldBe((int)HttpStatusCode.NotFound); }