public void Should_return_validation_error()
            {
                var sexDescriptor = new SexDescriptor
                {
                    SexDescriptorId = 1, CodeValue = "Code#Value", Namespace = "urn://<>#%{}|\\^~[]/<>#%{}|\\^~[]"
                };

                var validator = new DescriptorNamespaceValidator();
                var result    = validator.Validate(sexDescriptor);

                result.IsValid.ShouldBeFalse();
                result.Errors.Count.ShouldBe(4);

                result.Errors[0]
                .ToString()
                .ShouldBe("'urn' is not a valid value for namespace scheme. Namespaces must be prefixed with 'uri://'.");

                result.Errors[1]
                .ToString()
                .ShouldBe(
                    "'<>#%{}|\\^~[]' is not a valid value for organization name. Organization names may only contain alphanumeric and these special characters \"$-_.+!*'(),\".");

                result.Errors[2]
                .ToString()
                .ShouldBe(
                    "'<>#%{}|\\^~[]' is not a valid value for descriptor name. Descriptor names may only contain alphanumeric characters.");

                result.Errors[3]
                .ToString()
                .ShouldBe("'Code#Value' is not a valid value for Code Value. Code values may not contain '#'.");
            }
            public void Should_return_valid()
            {
                var sexDescriptor = new SexDescriptor
                {
                    SexDescriptorId = 1, CodeValue = "Male", Namespace = "uri://ed-fi.org/SexDescriptor"
                };

                var validator = new DescriptorNamespaceValidator();
                var result    = validator.Validate(sexDescriptor);

                result.IsValid.ShouldBeTrue();
                result.Errors.Count.ShouldBe(0);
            }
            public void Should_return_validation_error()
            {
                var sexDescriptor = new SexDescriptor
                {
                    SexDescriptorId = 1, CodeValue = "CodeValue", Namespace = "\t \r\n"
                };

                var validator = new DescriptorNamespaceValidator();
                var result    = validator.Validate(sexDescriptor);

                result.IsValid.ShouldBeFalse();
                result.Errors.Count.ShouldBe(1);

                result.Errors[0]
                .ToString()
                .ShouldBe("Namespace is required.");
            }
            public void Should_return_validation_error()
            {
                var sexDescriptor = new SexDescriptor
                {
                    SexDescriptorId = 1, CodeValue = "Code#Value", Namespace = "uri://ed-fi.org/SexDescriptor"
                };

                var validator = new DescriptorNamespaceValidator();
                var result    = validator.Validate(sexDescriptor);

                result.IsValid.ShouldBeFalse();
                result.Errors.Count.ShouldBe(1);

                result.Errors.First()
                .ToString()
                .ShouldBe("'Code#Value' is not a valid value for Code Value. Code values may not contain '#'.");
            }
            public void Should_return_validation_error()
            {
                var sexDescriptor = new SexDescriptor
                {
                    SexDescriptorId = 1, CodeValue = string.Empty, Namespace = "uri://ed-fi.org/SexDescriptor"
                };

                var validator = new DescriptorNamespaceValidator();
                var result    = validator.Validate(sexDescriptor);

                result.IsValid.ShouldBeFalse();
                result.Errors.Count.ShouldBe(1);

                result.Errors[0]
                .ToString()
                .ShouldBe("Code Value is required.");
            }
            public void Should_return_validation_error()
            {
                var sexDescriptor = new SexDescriptor
                {
                    SexDescriptorId = 1, CodeValue = "CodeValue", Namespace = "urn://ed-fi.org/SexDescriptor"
                };

                var validator = new DescriptorNamespaceValidator();
                var result    = validator.Validate(sexDescriptor);

                result.IsValid.ShouldBeFalse();
                result.Errors.Count.ShouldBe(1);

                result.Errors.First()
                .ToString()
                .ShouldBe("'urn' is not a valid value for namespace scheme. Namespaces must be prefixed with 'uri://'.");
            }
            public void Should_return_validation_error()
            {
                var sexDescriptor = new SexDescriptor
                {
                    SexDescriptorId = 1, CodeValue = "CodeValue", Namespace = "uri:///SexDescriptor"
                };

                var validator = new DescriptorNamespaceValidator();
                var result    = validator.Validate(sexDescriptor);

                result.IsValid.ShouldBeFalse();
                result.Errors.Count.ShouldBe(1);

                result.Errors[0]
                .ToString()
                .ShouldBe(
                    "organization name is required. Valid namespace format is uri://[organization name]/[descriptor name]. Example: 'uri://ed-fi.org/AcademicSubjectDescriptor'");
            }
            public void Should_return_validation_error()
            {
                var sexDescriptor = new SexDescriptor
                {
                    SexDescriptorId = 1, CodeValue = "CodeValue", Namespace = "uri://ed-fi.org/<>#%{}|\\^~[]"
                };

                var validator = new DescriptorNamespaceValidator();
                var result    = validator.Validate(sexDescriptor);

                result.IsValid.ShouldBeFalse();
                result.Errors.Count.ShouldBe(1);

                result.Errors.First()
                .ToString()
                .ShouldBe(
                    "'<>#%{}|\\^~[]' is not a valid value for descriptor name. Descriptor names may only contain alphanumeric characters.");
            }
            public void Should_return_validation_error()
            {
                var sexDescriptor = new SexDescriptor
                {
                    SexDescriptorId = 1, CodeValue = "CodeValue", Namespace = "uri://<>#%{}|\\^~[]/SexDescriptor"
                };

                var validator = new DescriptorNamespaceValidator();
                var result    = validator.Validate(sexDescriptor);

                result.IsValid.ShouldBeFalse();
                result.Errors.Count.ShouldBe(1);

                result.Errors.First()
                .ToString()
                .ShouldBe(
                    "'<>#%{}|\\^~[]' is not a valid value for organization name. Organization names may only contain alphanumeric and these special characters \"$-_.+!*'(),\".");
            }
            public void Should_return_validation_error()
            {
                var sexDescriptor = new SexDescriptor
                {
                    SexDescriptorId = 1, CodeValue = "Code#Value", Namespace = "InvalidNamespaceFormat"
                };

                var validator = new DescriptorNamespaceValidator();
                var result    = validator.Validate(sexDescriptor);

                result.IsValid.ShouldBeFalse();
                result.Errors.Count.ShouldBe(2);

                result.Errors[0]
                .ToString()
                .ShouldBe(
                    "Namespace has invalid format. Valid namespace format is uri://[organization name]/[descriptor name]. Example: 'uri://ed-fi.org/AcademicSubjectDescriptor'");

                result.Errors[1]
                .ToString()
                .ShouldBe("'Code#Value' is not a valid value for Code Value. Code values may not contain '#'.");
            }