예제 #1
0
        public async Task Cannot_add_ManagementStaff_when_it_already_exists()
        {
            const string MANAGEMENT_STAFF_ID = "EMP11";
            const string FIRST_NAME          = "First Name";
            const string LAST_NAME           = "Last Name";
            const string MOBILE = "0718958874";

            using (var context = new ProcurementDbContext(ContextOptions))
            {
                ManagementStaffsController managementStaffsController = new ManagementStaffsController(context);

                ManagementStaff managementStaff = new ManagementStaff {
                    StaffId = MANAGEMENT_STAFF_ID, FirstName = FIRST_NAME, LastName = LAST_NAME, MobileNo = MOBILE
                };

                try
                {
                    await managementStaffsController.PostManagementStaff(managementStaff);
                }
                catch (Exception exception)
                {
                    Assert.NotNull(exception);
                    return;
                }

                Assert.True(false);
            }
        }
예제 #2
0
        public async Task Can_add_new_ManagementStaff_when_it_not_existing()
        {
            const string MANAGEMENT_STAFF_ID = "EMP14";
            const string FIRST_NAME          = "First Name";
            const string LAST_NAME           = "Last Name";
            const string MOBILE = "0718958874";

            using (var context = new ProcurementDbContext(ContextOptions))
            {
                ManagementStaffsController managementStaffsController = new ManagementStaffsController(context);

                ManagementStaff managementStaff = new ManagementStaff {
                    StaffId = MANAGEMENT_STAFF_ID, FirstName = FIRST_NAME, LastName = LAST_NAME, MobileNo = MOBILE
                };

                var result = await managementStaffsController.PostManagementStaff(managementStaff);

                var viewResult   = Assert.IsType <ActionResult <ManagementStaff> >(result);
                var actionResult = Assert.IsType <CreatedAtActionResult>(viewResult.Result);
                var model        = Assert.IsType <ManagementStaff>(actionResult.Value);
                Assert.Equal(MANAGEMENT_STAFF_ID, model.StaffId);
            }
        }