public async Task ShouldReturnNotFoundIfDoesNotExist_GetModuleById() { int id = 56; var mockRepo = new Mock <IDataRepository>(); mockRepo.Setup(repo => repo.GetModuleAsync(id)). ReturnsAsync((Module)null); ModulesController controller = new ModulesController(mockRepo.Object); var result = await controller.GetModuleById(id); Assert.IsInstanceOfType(result.Result, typeof(NotFoundResult)); }