コード例 #1
0
        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"));
        }
コード例 #2
0
        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"));
        }
コード例 #3
0
        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"));
        }
コード例 #4
0
        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"));
        }