public void GetCypherByIdNotFound(int id) { // Given Mock <ICypherRepository> mockRepo = new Mock <ICypherRepository>(); mockRepo.Setup(repo => repo.Get(It.IsAny <int>())).Returns <int>((i) => { return(Task.FromResult(cyphers.FirstOrDefault(c => c.Id == i))); }); CyphersController controller = new CyphersController(mockRepo.Object); // When IActionResult result = controller.GetById(id); // Then Assert.NotNull(result); var objectResult = Assert.IsType <NotFoundResult>(result); }