-
Notifications
You must be signed in to change notification settings - Fork 48
Feature/issue-40 #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/issue-40 #41
Changes from all commits
a04af73
058d7e1
743598f
af60610
4777911
4b310d5
5a5662f
3d1f035
858ef20
69820b3
0e35a8f
1e8ebbd
025f592
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
using Newtonsoft.Json.Linq; | ||
using Xunit; | ||
using Xunit.Extensions; | ||
using System.IO; | ||
using Newtonsoft.Json; | ||
using JsonLD.Core; | ||
using JsonLD.Util; | ||
|
||
|
@@ -16,7 +13,7 @@ namespace JsonLD.Test | |
public class ConformanceTests | ||
{ | ||
[Theory, ClassData(typeof(ConformanceCases))] | ||
public void ConformanceTestPasses(string id, string testname, ConformanceCase conformanceCase) | ||
public void ConformanceTestPasses(string id, ConformanceCase conformanceCase) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
{ | ||
JToken result = conformanceCase.run(); | ||
if (conformanceCase.error != null) | ||
|
@@ -77,20 +74,21 @@ public ConformanceCases() | |
|
||
public IEnumerator<object[]> GetEnumerator() | ||
{ | ||
var jsonFetcher = new JsonFetcher(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I created the |
||
var rootDirectory = "W3C"; | ||
|
||
foreach (string manifest in manifests) | ||
{ | ||
JToken manifestJson; | ||
|
||
manifestJson = GetJson(manifest); | ||
JToken manifestJson = jsonFetcher.GetJson(manifest, rootDirectory); | ||
|
||
foreach (JObject testcase in manifestJson["sequence"]) | ||
{ | ||
Func<JToken> run; | ||
ConformanceCase newCase = new ConformanceCase(); | ||
|
||
newCase.input = GetJson(testcase["input"]); | ||
newCase.context = GetJson(testcase["context"]); | ||
newCase.frame = GetJson(testcase["frame"]); | ||
newCase.input = jsonFetcher.GetJson(testcase["input"], rootDirectory); | ||
newCase.context = jsonFetcher.GetJson(testcase["context"], rootDirectory); | ||
newCase.frame = jsonFetcher.GetJson(testcase["frame"], rootDirectory); | ||
|
||
var options = new JsonLdOptions("http://json-ld.org/test-suite/tests/" + (string)testcase["input"]); | ||
|
||
|
@@ -109,11 +107,11 @@ public IEnumerator<object[]> GetEnumerator() | |
else if (testType.Any((s) => (string)s == "jld:FromRDFTest")) | ||
{ | ||
newCase.input = File.ReadAllText(Path.Combine("W3C", (string)testcase["input"])); | ||
newCase.output = GetJson(testcase["expect"]); | ||
newCase.output = jsonFetcher.GetJson(testcase["expect"], rootDirectory); | ||
} | ||
else | ||
{ | ||
newCase.output = GetJson(testcase["expect"]); | ||
newCase.output = jsonFetcher.GetJson(testcase["expect"], rootDirectory); | ||
} | ||
} | ||
else | ||
|
@@ -138,7 +136,7 @@ public IEnumerator<object[]> GetEnumerator() | |
} | ||
if (optionDescription.TryGetValue("expandContext", out value)) | ||
{ | ||
newCase.context = GetJson(testcase["option"]["expandContext"]); | ||
newCase.context = jsonFetcher.GetJson(testcase["option"]["expandContext"], rootDirectory); | ||
options.SetExpandContext((JObject)newCase.context); | ||
} | ||
if (optionDescription.TryGetValue("produceGeneralizedRdf", out value)) | ||
|
@@ -227,32 +225,11 @@ public IEnumerator<object[]> GetEnumerator() | |
|
||
newCase.run = run; | ||
|
||
yield return new object[] { manifest + (string)testcase["@id"], (string)testcase["name"], newCase }; | ||
yield return new object[] { manifest + (string)testcase["@id"], newCase }; | ||
} | ||
} | ||
} | ||
|
||
private JToken GetJson(JToken j) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved to the |
||
{ | ||
try | ||
{ | ||
if (j == null || j.Type == JTokenType.Null) return null; | ||
using (Stream manifestStream = File.OpenRead(Path.Combine("W3C", (string)j))) | ||
using (TextReader reader = new StreamReader(manifestStream)) | ||
using (JsonReader jreader = new Newtonsoft.Json.JsonTextReader(reader) | ||
{ | ||
DateParseHandling = DateParseHandling.None | ||
}) | ||
{ | ||
return JToken.ReadFrom(jreader); | ||
} | ||
} | ||
catch (Exception e) | ||
{ // TODO: this should not be here, figure out why this is needed or catch specific exception. | ||
return null; | ||
} | ||
} | ||
|
||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() | ||
{ | ||
throw new Exception("auggh"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"quads": [ | ||
{ | ||
"graph": "http://example.org/node/3", | ||
"subject": "http://example.org/object/3", | ||
"predicate": "http://example.org/value", | ||
"value": "n3-o3-value" | ||
}, | ||
{ | ||
"graph": "http://example.org/node/3", | ||
"subject": "http://example.org/object/1", | ||
"predicate": "http://example.org/value", | ||
"value": "n3-o1-value" | ||
}, | ||
{ | ||
"graph": "http://example.org/node/3", | ||
"subject": "http://example.org/object/2", | ||
"predicate": "http://example.org/value", | ||
"value": "n3-o2-value" | ||
}, | ||
{ | ||
"graph": "http://example.org/node/1", | ||
"subject": "http://example.org/object/3", | ||
"predicate": "http://example.org/value", | ||
"value": "n1-o3-value" | ||
}, | ||
{ | ||
"graph": "http://example.org/node/1", | ||
"subject": "http://example.org/object/1", | ||
"predicate": "http://example.org/value", | ||
"value": "n1-o1-value" | ||
}, | ||
{ | ||
"graph": "http://example.org/node/1", | ||
"subject": "http://example.org/object/2", | ||
"predicate": "http://example.org/value", | ||
"value": "n1-o2-value" | ||
}, | ||
{ | ||
"graph": "http://example.org/node/2", | ||
"subject": "http://example.org/object/3", | ||
"predicate": "http://example.org/value", | ||
"value": "n2-o3-value" | ||
}, | ||
{ | ||
"graph": "http://example.org/node/2", | ||
"subject": "http://example.org/object/1", | ||
"predicate": "http://example.org/value", | ||
"value": "n2-o1-value" | ||
}, | ||
{ | ||
"graph": "http://example.org/node/2", | ||
"subject": "http://example.org/object/2", | ||
"predicate": "http://example.org/value", | ||
"value": "n2-o2-value" | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"@type": "mf:Manifest", | ||
"name": "From RDF", | ||
"description": "JSON-LD sorting graphs and nodes when running FromRDF", | ||
"input": "fromRdf-in.json", | ||
"sequence": [ | ||
{ | ||
"@id": "#t0001", | ||
"sort-type": "jld:GraphsAndNodes", | ||
"test-type": "jld:FromRDF", | ||
"name": "sort graphs and nodes", | ||
"purpose": "graphs and nodes sorted when running FromRDF", | ||
"expect": "fromRdf-out-sort-graphs-and-nodes.jsonld" | ||
}, | ||
{ | ||
"@id": "#t0002", | ||
"sort-type": "jld:Graphs", | ||
"test-type": "jld:FromRDF", | ||
"name": "sort graphs only", | ||
"purpose": "graphs sorted when running FromRDF", | ||
"expect": "fromRdf-out-sort-graphs.jsonld" | ||
}, | ||
{ | ||
"@id": "#t0003", | ||
"sort-type": "jld:Nodes", | ||
"test-type": "jld:FromRDF", | ||
"name": "sort graph nodes only", | ||
"purpose": "graph nodes sorted when running FromRDF", | ||
"expect": "fromRdf-out-sort-graph-nodes.jsonld" | ||
}, | ||
{ | ||
"@id": "#t0004", | ||
"sort-type": "jld:None", | ||
"test-type": "jld:FromRDF", | ||
"name": "sort nothing", | ||
"purpose": "sort nothing running FromRDF", | ||
"expect": "fromRdf-out-no-sorting.jsonld" | ||
} | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I've only been able to control the order with the
FromRDF
method (which luckily is all that's needed to get the desired behavior), I made the option pretty narrow in scope.