コード例 #1
0
        public void Consume_validation_results()
        {
            var dataGraph = new Graph();

            dataGraph.LoadFromString(@"
@prefix : <urn:> .

:s :p :o .
");

            var shapesGraph = new Graph();

            shapesGraph.LoadFromString(@"
@prefix : <urn:> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

[
    sh:targetNode :s ;
    sh:property [
        sh:path :p ;
        sh:class :C ;
        sh:message ""test message"" ;
    ]
] .
");

            var processor = new ShapesGraph(shapesGraph);
            var report    = processor.Validate(dataGraph);

            var result = report.Results.Single();

            Assert.Equal("test message", result.Message.Value);
        }
コード例 #2
0
        public void Validation()
        {
            var dataGraph = new Graph();

            dataGraph.LoadFromString(@"
@prefix : <urn:> .

:s :p :o .
");

            var shapesGraph = new Graph();

            shapesGraph.LoadFromString(@"
@prefix : <urn:> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

[
    sh:targetNode :s ;
    sh:property [
        sh:path :p ;
        sh:class :C
    ]
] .
");

            var reportGraph = new Graph();

            reportGraph.LoadFromString(@"
@prefix : <urn:> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

[
    a sh:ValidationReport ;
    sh:conforms false ;
    sh:result [
        a sh:ValidationResult ;
        sh:resultMessage ""Value node must be an instance of type urn:C."" ;
        sh:sourceConstraintComponent sh:ClassConstraintComponent ;
        sh:resultSeverity sh:Violation ;
        sh:sourceShape [] ;
        sh:focusNode :s ;
        sh:resultPath :p ;
        sh:value :o
    ]
] .
");

            var processor = new ShapesGraph(shapesGraph);
            var report    = processor.Validate(dataGraph);

            Assert.Equal(reportGraph, report.Graph);
        }