Esempio n. 1
0
        public void Triggering_all_validtors_returns_right_ErrorCode()
        {
            var client  = GetClient();
            var request = new TriggerValidators
            {
                CreditCard         = "NotCreditCard",
                Email              = "NotEmail",
                Empty              = "NotEmpty",
                Equal              = "NotEqual",
                ExclusiveBetween   = 1,
                GreaterThan        = 1,
                GreaterThanOrEqual = 1,
                InclusiveBetween   = 1,
                Length             = "Length",
                LessThan           = 20,
                LessThanOrEqual    = 20,
                NotEmpty           = "",
                NotEqual           = "NotEqual",
                Null = "NotNull",
                RegularExpression = "FOO",
                ScalePrecision    = 123.456m
            };

            try
            {
                var response = client.Post(request);
                Assert.Fail("Should throw");
            }
            catch (WebServiceException ex)
            {
                //ex.ResponseStatus.PrintDump();
                var errors = ex.ResponseStatus.Errors;
                Assert.That(errors.First(x => x.FieldName == "CreditCard").ErrorCode, Is.EqualTo("CreditCard"));
                Assert.That(errors.First(x => x.FieldName == "Email").ErrorCode, Is.EqualTo("Email"));
                Assert.That(errors.First(x => x.FieldName == "Email").ErrorCode, Is.EqualTo("Email"));
                Assert.That(errors.First(x => x.FieldName == "Empty").ErrorCode, Is.EqualTo("Empty"));
                Assert.That(errors.First(x => x.FieldName == "Equal").ErrorCode, Is.EqualTo("Equal"));
                Assert.That(errors.First(x => x.FieldName == "ExclusiveBetween").ErrorCode, Is.EqualTo("ExclusiveBetween"));
                Assert.That(errors.First(x => x.FieldName == "GreaterThan").ErrorCode, Is.EqualTo("GreaterThan"));
                Assert.That(errors.First(x => x.FieldName == "GreaterThanOrEqual").ErrorCode, Is.EqualTo("GreaterThanOrEqual"));
                Assert.That(errors.First(x => x.FieldName == "InclusiveBetween").ErrorCode, Is.EqualTo("InclusiveBetween"));
                Assert.That(errors.First(x => x.FieldName == "Length").ErrorCode, Is.EqualTo("Length"));
                Assert.That(errors.First(x => x.FieldName == "LessThan").ErrorCode, Is.EqualTo("LessThan"));
                Assert.That(errors.First(x => x.FieldName == "LessThanOrEqual").ErrorCode, Is.EqualTo("LessThanOrEqual"));
                Assert.That(errors.First(x => x.FieldName == "NotEmpty").ErrorCode, Is.EqualTo("NotEmpty"));
                Assert.That(errors.First(x => x.FieldName == "NotEqual").ErrorCode, Is.EqualTo("NotEqual"));
                Assert.That(errors.First(x => x.FieldName == "Null").ErrorCode, Is.EqualTo("Null"));
                Assert.That(errors.First(x => x.FieldName == "RegularExpression").ErrorCode, Is.EqualTo("RegularExpression"));
                Assert.That(errors.First(x => x.FieldName == "ScalePrecision").ErrorCode, Is.EqualTo("ScalePrecision"));
            }
        }
Esempio n. 2
0
        public static TriggerValidators CreateTriggerValidators()
        {
            var request = new TriggerValidators {
                CreditCard         = "NotCreditCard",
                Email              = "NotEmail",
                Empty              = "NotEmpty",
                Equal              = "NotEqual",
                ExclusiveBetween   = 1,
                GreaterThan        = 1,
                GreaterThanOrEqual = 1,
                InclusiveBetween   = 1,
                Length             = "Length",
                LessThan           = 20,
                LessThanOrEqual    = 20,
                NotEmpty           = "",
                NotEqual           = "NotEqual",
                Null = "NotNull",
                RegularExpression = "FOO",
                ScalePrecision    = 123.456m
            };

            return(request);
        }
Esempio n. 3
0
 public object Any(TriggerValidators request) => request;