public void RegisterWithInvalidPhoneNumber() { RegistrationRequest request = new RegistrationRequest() { Phone = "123" }; ClassRegistration result = ClassRegistration.Process(request, new[] { new PhoneValidator() }); Assert.AreEqual("A phone number is required", result.GetError("Phone")); }
public void RegisterWithPaymentAmountOutsideAllowableRange() { RegistrationRequest request = new RegistrationRequest() { PaymentAmount = "600" }; ClassRegistration result = ClassRegistration.Process(request, new[] { new PaymentAmountValidator(5, 500) }); Assert.AreEqual("Payment amount must be between $5 and $500", result.GetError("PaymentAmount")); }
public void RegisterWithInvalidEmailAddress() { RegistrationRequest request = new RegistrationRequest() { Name = "Joe", Email = "Smith@ish" }; ClassRegistration result = ClassRegistration.Process(request, new[] { new EmailValidator() }); Assert.AreEqual("A valid email address is required", result.GetError("Email")); }
public void RegisterWithNameMissing() { RegistrationRequest request = new RegistrationRequest() { Name = null, }; ClassRegistration result = ClassRegistration.Process(request, null); Assert.IsFalse(result.IsValid); Assert.AreEqual("Name is required", result.GetError("Name")); }