private async Task <IEnumerable <Employee> > GetListOfOneEmployeeById(IReadOnlyList <string> keys, int num) { var id = ParseNumber(keys[num - 1]); var employee = await _service.FindByIdAsync(id); return(employee == null ? null : ConvertToArray(employee)); }
public async Task EmployeeDirectoryService_FindByIdAsync_should_return_null_for_unknown_id() { var service = new EmployeeDirectoryService(TestEmployeeDbContext.GetTestDbContext()); var result = await service.FindByIdAsync(9999); Assert.IsNull(result); }
public async Task EmployeeDirectoryService_FindByIdAsync_should_return_joe_for_id_1() { var service = new EmployeeDirectoryService(TestEmployeeDbContext.GetTestDbContext()); var result = await service.FindByIdAsync(1); AssertEmployeeIs("Joe Programmer", result); }
// The Home controller is just to validate that our app is working. public async Task <ActionResult> Index() { using (var context = new EmployeeDbContext()) { var service = new EmployeeDirectoryService(context); ViewBag.FirstEmployee = await service.FindByIdAsync(1); } return(View()); }