public async Task Can_get_all_AccountingStaff_in_database() { using (var context = new ProcurementDbContext(ContextOptions)) { AccountingStaffsController accountingStaffsController = new AccountingStaffsController(context); var result = await accountingStaffsController.GetAccountingStaff(); var viewResult = Assert.IsType <ActionResult <IEnumerable <AccountingStaff> > >(result); var model = Assert.IsType <List <AccountingStaff> >(viewResult.Value); Assert.Equal(3, model.Count); } }
public async Task Should_not_return_AccountingStaff_when_unavailable() { const string ACCOUNTING_STAFF_ID = "EMP100"; using (var context = new ProcurementDbContext(ContextOptions)) { AccountingStaffsController accountingStaffsController = new AccountingStaffsController(context); var result = await accountingStaffsController.GetAccountingStaff(ACCOUNTING_STAFF_ID); var viewResult = Assert.IsType <ActionResult <AccountingStaff> >(result); Assert.IsNotType <AccountingStaff>(viewResult.Value); var response = Assert.IsType <NotFoundResult>(viewResult.Result); Assert.Equal(404, response.StatusCode); } }
public async Task Can_get_AccountingStaff_By_Id() { const string ACCOUNTING_STAFF_ID = "EMP21"; using (var context = new ProcurementDbContext(ContextOptions)) { AccountingStaffsController accountingStaffsController = new AccountingStaffsController(context); var result = await accountingStaffsController.GetAccountingStaff(ACCOUNTING_STAFF_ID); var viewResult = Assert.IsType <ActionResult <AccountingStaff> >(result); var model = Assert.IsType <AccountingStaff>(viewResult.Value); Assert.Equal(ACCOUNTING_STAFF_ID, model.StaffId); } }