public void EmulateAtNextLogon_UserIdNotValid() { var model = new ProvisionerModel { UserId = null, Reason = "Reason", JobNumber = "1234567" }; SystemUnderTest().EmulateAtNextLogon(model); }
public void EmulateAtNextLogon_JobNumberNotValid() { var model = new ProvisionerModel { UserId = "AA123456", Reason = "", JobNumber = null }; SystemUnderTest().EmulateAtNextLogon(model); }
public static ProvisionerModel ToProvisionerModel(this DepartmentEmulateUser src) { var dest = new ProvisionerModel(); dest.JobNumber = src.JobNumber; dest.Reason = src.Reason; dest.UserId = src.UserId; return(dest); }
public void EmulateAtNextLogon_Valid() { var model = new ProvisionerModel { UserId = "AB000012", Reason = "Reason", JobNumber = "1234567" }; var result = SystemUnderTest().EmulateAtNextLogon(model); Assert.IsTrue(result); }
public bool EmulateAtNextLogon(ProvisionerModel model) { try { var errors = new Dictionary <string, string>(); if (string.IsNullOrEmpty(model.UserId) || (model.UserId.Length <= 0) || (model.UserId.Length > 10)) { errors.Add("UserId", "User Id is required and must be under 10 characters."); } if (string.IsNullOrEmpty(model.JobNumber) && (string.IsNullOrEmpty(model.Reason))) { errors.Add("JobNumber", "You must enter a job number or a reason."); } if (!string.IsNullOrEmpty(model.JobNumber) && model.JobNumber.Length > 20) { errors.Add("JobNumber", "The job number is too long."); } if (!string.IsNullOrEmpty(model.Reason) && (model.Reason.Length > 200)) { errors.Add("Reason", "The reason is too long."); } if (errors.Count > 0) { throw new ServiceValidationException(errors); } var service = Client.Create <ISmartClientProvisioner>("SmartClientProvisioner.svc"); return(service.EmulateAtNextLogon(model.UserId, model.JobNumber, model.Reason)); } catch (FaultException <ValidationFault> vf) { throw vf.ToServiceValidationException(); } catch (FaultException fe) { throw fe.ToServiceValidationException(); } }
public ActionResult DepartmentEmulateUser(DepartmentEmulateUser emulateUser) { if (ModelState.IsValid) { ProvisionerModel emulate = emulateUser.ToProvisionerModel(); // MappingEngine.Map<ProvisionerModel>(emulateUser); try { var result = ProvisionerService.EmulateAtNextLogon(emulate); if (result) { AddInformationMessage("User will be emulated at next logon. Restart your browser"); return(View(emulateUser)); } } catch (ServiceValidationException) { AddErrorMessage("User Emulate Failed."); return(View(emulateUser)); } } AddErrorMessage("User Emulate Failed."); return(View(emulateUser)); }