Ejemplo n.º 1
0
        public void given_valid_request_when_validating_should_return_no_errors()
        {
            var request = GetValidRequest();

            ICollection <ValidationResult> results;
            var validator = new DataAnnotationsValidator();

            validator.TryValidate(request, out results).Should().BeTrue();
            results.Should().BeEmpty();
        }
        public void given_valid_service_type_when_validating_should_return_no_errors()
        {
            var serviceType = new ServiceType {
                Code = "CODE", Description = "DESCRIPTION"
            };

            ICollection <ValidationResult> results;
            var validator = new DataAnnotationsValidator();

            validator.TryValidate(serviceType, out results).Should().BeTrue();
            results.Should().BeEmpty();
        }
        public void given_invalid_service_type_when_validating_should_return_errors()
        {
            var serviceType = new ServiceType {
                Code = string.Empty, Description = null
            };

            ICollection <ValidationResult> results;
            var validator = new DataAnnotationsValidator();

            validator.TryValidate(serviceType, out results).Should().BeFalse();

            results.Count.Should().Be(2);
            var messages = results.Select(r => r.ErrorMessage).ToList();

            messages.Should().Contain("The Code field is required.");
            messages.Should().Contain("The Description field is required.");
        }
Ejemplo n.º 4
0
        public void given_invalid_request_when_validating_should_return_errors()
        {
            var request = new EligibilityScrapeRequest
            {
                RequestExpiration  = null,
                ApplicationId      = Guid.Empty,
                ResponseAddress    = "*****@*****.**",
                PlanCode           = null,
                PlanDescription    = null,
                SubscriberId       = null,
                PatientDateOfBirth = DateTime.MinValue,
                ProviderId         = null,
                ServiceDate        = DateTime.MinValue,
                ServiceTypes       = new [] { new ServiceType {
                                                  Code = "CODE", Description = "DESCRIPTION"
                                              }, new ServiceType()
                                              {
                                                  Code = null, Description = string.Empty
                                              } }
            };

            ICollection <ValidationResult> results;
            var validator = new DataAnnotationsValidator();

            validator.TryValidate(request, out results).Should().BeFalse();


            results.Count.Should().BeGreaterThan(1);
            var messages = results.Select(r => r.ErrorMessage);

            messages.Contains("The CorrelationId field requires a non-default value.");
            messages.Contains("The ApplicationId field requires a non-default value.");
            messages.Contains("The ResponseAddress field is not a valid fully-qualified http, https, or ftp URL.");
            messages.Contains("The PlanCode field is required.");
            messages.Contains("The PlanDescription field is required.");
            messages.Contains("The SubscriberId field is required.");
            messages.Contains("The PatientDateOfBirth field requires a non-default value.");
            messages.Contains("The ProviderId field is required.");
            messages.Contains("The ServiceDate field requires a non-default value.");
            messages.Contains("The ServiceTypes field is not valid.");
        }
Ejemplo n.º 5
0
        public void given_invalid_service_type_when_validating_should_return_errors()
        {
            var request = GetValidRequest(r =>
            {
                r.ServiceTypes = new[] { new ServiceType {
                                             Code = null, Description = string.Empty
                                         } };
                return(r);
            });

            ICollection <ValidationResult> results;
            var validator = new DataAnnotationsValidator();

            validator.TryValidate(request, out results).Should().BeFalse();


            results.Count.Should().Be(1);
            var messages = results.Select(r => r.ErrorMessage);

            messages.Contains("The Code field is required.");
            messages.Contains("The Description field is required.");
        }