public void TestModelValidationFail() { var target = new PatientOnBoardShortDetailRequest(); var thrown = Assert.Throws <Exception>(() => target.ValidateModel(m => new Exception(m))); Assert.AreEqual("First name required.", thrown.Message); target.FirstName = "First Name"; thrown = Assert.Throws <Exception>(() => target.ValidateModel(m => new Exception(m))); Assert.AreEqual("Email address required.", thrown.Message); target.Email = "*****@*****.**"; thrown = Assert.Throws <Exception>(() => target.ValidateModel(m => new Exception(m))); Assert.AreEqual("Unknown gender. Expected gender any [M, F]", thrown.Message); target.Gender = "F"; thrown = Assert.Throws <Exception>(() => target.ValidateModel(m => new Exception(m))); Assert.AreEqual("Date of birth required.", thrown.Message); target.Dob = new DateTime(2015, 1, 1); thrown = Assert.Throws <Exception>(() => target.ValidateModel(m => new Exception(m))); Assert.AreEqual("Address required.", thrown.Message); target.Address = "I.R. Address"; thrown = Assert.Throws <Exception>(() => target.ValidateModel(m => new Exception(m))); Assert.AreEqual("Mobile number required.", thrown.Message); target.MobileNumberWithCountryCode = "12345678900"; bool actual = target.ValidateModel(m => new Exception(m)); Assert.IsTrue(actual); }
public ApiResponseV2 <AddPatientAdminResponseShort> AddPatient(PatientOnBoardShortDetailRequest patient, bool allowNullEmail) { if (patient.ValidateModel(message => new SnapSdkException(message), allowNullEmail)) { return(Post <ApiResponseV2 <AddPatientAdminResponseShort> >("v2/admin/patients", patient)); } throw new SnapSdkException("Patient model is missing values"); }
public void TestModelValidationAllowsNullEmail() { var target = new PatientOnBoardShortDetailRequest { FirstName = "First Name", Email = null, Dob = new DateTime(2015, 1, 1), Address = "I.R. Address", MobileNumberWithCountryCode = "12345678900", Gender = "F" }; bool actual = target.ValidateModel(m => new Exception(m), true); Assert.IsTrue(actual); }
public ApiResponseV2 <AddPatientAdminResponseShort> AddPatient(PatientOnBoardShortDetailRequest patient) { return(AddPatient(patient, false)); }