상속: IRecordValidator
예제 #1
0
        public void go()
        {
            var query = Db.Query<Record>().Where(r => r.Gemini.Title == "Broadscale remote survey and mapping of sublittoral habitats and their associated biota in the Firth of Lorn: biotopes");

            var record = query.First();

            record.Should().NotBeNull();

            record.Validation = Validation.Gemini;
            record.Gemini.LimitationsOnPublicAccess = "this is a test record so shouldn't be viewed by anyone ...";

            var validator = new RecordValidator();
            var result = validator.Validate(record);

            var xml = new global::Catalogue.Gemini.Encoding.XmlEncoder().Create(new Guid("a92a3e00-2ff6-4270-b19e-377c7d542d7c"), Library.Example());
            var ceh = new global::Catalogue.Gemini.Validation.Validator().Validate(xml);

            xml.Save(@"c:\topcat-out.xml");
        }
예제 #2
0
        public void title_must_not_be_londer_then_200([Values("", " ", null)] string blank)
        {
            var result =
                new RecordValidator().Validate(SimpleRecord().With(r => r.Gemini.Title = new String('x', 201)));

            result.Errors.Single().Message.Should().StartWith("Title is too long. 200 characters or less, please");
            result.Errors.Single().Fields.Single().Should().Be("gemini.title");
        }
예제 #3
0
        public void title_must_not_be_blank([Values("", " ", null)] string blank)
        {
            var result =
                new RecordValidator().Validate(SimpleRecord().With(r => r.Gemini.Title = blank));

            result.Errors.Single().Message.Should().StartWith("Title must not be blank");
            result.Errors.Single().Fields.Single().Should().Be("gemini.title");
        }
예제 #4
0
        public void should_produce_no_warnings_by_default()
        {
            // the basic level of validation shouldn't produce warnings - that would be too annoying

            var result = new RecordValidator().Validate(SimpleRecord() /* no Level argument */);
            result.Warnings.Should().BeEmpty();
        }
예제 #5
0
        public void jncc_keywords_must_be_provided()
        {
            // should not validate on empty list
            var r1 =
               new RecordValidator().Validate(SimpleRecord().With(r => r.Gemini.Keywords = new List<MetadataKeyword>()));

            r1.Errors.First().Message.Should().StartWith("Must specify a JNCC Domain");
        }
예제 #6
0
        public void should_validate_valid_nonspatial_record_with_no_bbox()
        {
            // to keep things comceptually simple, let's try to keep one level of "good" validation - "gemini"
            // but use it for non-spatial metadata too

            var record = GeminiRecord().With(r =>
                {
                    r.Gemini.ResourceType = "nonGeographicDataset";
                    r.Gemini.BoundingBox = null;
                });

            var result = new RecordValidator().Validate(record);

            result.Errors.Count.Should().Be(0);
        }
예제 #7
0
 public void responsible_organisation_role_must_not_be_blank()
 {
     var record = GeminiRecord().With(r => r.Gemini.ResponsibleOrganisation = new ResponsibleParty
     {
         Email = "*****@*****.**",
         Name = "A. Mann",
         Role = "",
     });
     var result = new RecordValidator().Validate(record);
     result.Errors.Single().Fields.Should().Contain("gemini.responsibleOrganisation.role");
 }
예제 #8
0
        public void blank_lineage_is_not_allowed([Values("", " ", null)] string blank)
        {
            var record = GeminiRecord().With(r => r.Gemini.Lineage = blank);
            var result = new RecordValidator().Validate(record);

            result.Errors.Any(e => e.Fields.Contains("gemini.lineage")).Should().BeTrue();
        }
예제 #9
0
        public void path_must_not_be_blank([Values("", " ", null)] string blank)
        {
            var result = new RecordValidator().Validate(SimpleRecord().With(r => r.Path = blank));

            result.Errors.Single().Fields.Single().Should().Be("path");
        }
예제 #10
0
 public void path_must_be_valid()
 {
     var result = new RecordValidator().Validate(SimpleRecord().With(r => r.Path = "not a valid path"));
     result.Errors.Single().Fields.Single().Should().Be("path");
 }
예제 #11
0
 public void path_must_be_an_acceptable_kind([Values(@"X:\some\path", "PG:\"host=spatial-store dbname=spatial layer=SSSI_England_Units\"")] string path)
 {
     var result = new RecordValidator().Validate(SimpleRecord().With(r => r.Path = path));
     result.Errors.Should().BeEmpty();
 }
예제 #12
0
 public void metadata_point_of_contact_role_must_be_an_allowed_role()
 {
     var record = SimpleRecord().With(r => r.Gemini.MetadataPointOfContact = new ResponsibleParty
     {
         Email = "*****@*****.**",
         Name = "A. Mann",
         Role = "some role that isn't allowed",
     });
     var result = new RecordValidator().Validate(record);
     result.Errors.Single().Fields.Should().Contain("gemini.metadataPointOfContact.role");
 }
예제 #13
0
 public void mesh_gui_keywords_must_be_of_valid_form()
 {
     var record = SimpleRecord().With(r => r.Gemini.Keywords.Add(new MetadataKeyword {Vocab = "http://vocab.jncc.gov.uk/mesh-gui", Value = "blah"} ));
     var result = new RecordValidator().Validate(record);
     result.Errors.Single().Fields.Should().Contain("gemini.keywords");
 }
예제 #14
0
        public void keywords_may_not_be_blank()
        {
            var record = SimpleRecord();
            record.Gemini.Keywords.Add(new MetadataKeyword() { Value = String.Empty, Vocab = String.Empty });

            var result =
                new RecordValidator().Validate(record);

            result.Errors.Single().Message.Should().StartWith("Keywords cannot be blank");
            result.Errors.Single().Fields.Single().Should().Be("gemini.keywords");
        }
예제 #15
0
 public void topic_category_may_be_blank([Values("", null)] string blank)
 {
     var record = SimpleRecord().With(r => r.Gemini.TopicCategory = blank);
     var result = new RecordValidator().Validate(record);
     result.Errors.Should().BeEmpty();
 }
예제 #16
0
        public void topic_category_must_be_valid()
        {
            var record = SimpleRecord().With(r => r.Gemini.TopicCategory = "anInvalidTopicCategory");
            var result = new RecordValidator().Validate(record);

            result.Errors.Single().Message.Should().Contain("Topic Category 'anInvalidTopicCategory' is not valid");
            result.Errors.Single().Fields.Single().Should().Be("gemini.topicCategory");
        }
예제 #17
0
        public void publication_title_can_be_londer_then_150([Values("", " ", null)] string blank)
        {
            var result =
                new RecordValidator().Validate(SimpleRecord().With(r =>
                {
                    r.Gemini.Title = new String('x', 155);
                    r.Gemini.ResourceType = "publication";
                }));

            result.Errors.Count().Should().Be(0);
        }
예제 #18
0
        public void blank_use_constraints_are_not_allowed([Values("", " ", null)] string blank)
        {
            var record = GeminiRecord().With(r => r.Gemini.UseConstraints = blank);
            var result = new RecordValidator().Validate(record);

            result.Errors.Any(e => e.Fields.Contains("gemini.useConstraints")).Should().BeTrue();
        }
예제 #19
0
 public void resource_locator_may_be_set()
 {
     var record = SimpleRecord().With(r => r.Gemini.ResourceLocator = "http://example.org/resource/locator");
     var result = new RecordValidator().Validate(record);
     result.Errors.Should().BeEmpty();
 }
예제 #20
0
        public void should_validate_valid_gemini_record()
        {
            var record = GeminiRecord();

            var result = new RecordValidator().Validate(record);

            result.Errors.Count.Should().Be(0);
        }
예제 #21
0
 public void resource_locator_must_be_a_well_formed_http_url(
     [Values(@"Z:\some\path", "utter rubbish")] string nonHttpUrl)
 {
     var record = SimpleRecord().With(r => r.Gemini.ResourceLocator = nonHttpUrl);
     var result = new RecordValidator().Validate(record);
     result.Errors.Single().Fields.Should().Contain("gemini.resourceLocator");
 }
예제 #22
0
        public void topic_category_must_not_be_blank([Values("", " ", null)] string blank)
        {
            var record = GeminiRecord().With(r => r.Gemini.TopicCategory = blank);
            var result = new RecordValidator().Validate(record);

            result.Errors.Any(e => e.Fields.Contains("gemini.topicCategory")).Should().BeTrue();
        }
예제 #23
0
        public void sensitive_records_must_have_limitations_on_public_access(
            [Values(Security.Secret, Security.OfficialSensitive)] Security nonOpen, [Values("", " ", null)] string blank)
        {
            var record = SimpleRecord().With(r =>
            {
                r.Security = nonOpen;
                r.Gemini.LimitationsOnPublicAccess = blank;
            });

            var result = new RecordValidator().Validate(record);

            result.Errors.Single().Fields.Should().Contain("security");
            result.Errors.Single().Fields.Should().Contain("gemini.limitationsOnPublicAccess");
        }