11using System ;
22using System . Collections . Generic ;
33using System . Linq ;
4- using System . Text ;
54
65using Newtonsoft . Json . Linq ;
76using Xunit ;
8- using Xunit . Extensions ;
97using System . IO ;
10- using Newtonsoft . Json ;
118using JsonLD . Core ;
129using JsonLD . Util ;
1310
@@ -16,7 +13,7 @@ namespace JsonLD.Test
1613 public class ConformanceTests
1714 {
1815 [ Theory , ClassData ( typeof ( ConformanceCases ) ) ]
19- public void ConformanceTestPasses ( string id , string testname , ConformanceCase conformanceCase )
16+ public void ConformanceTestPasses ( string id , ConformanceCase conformanceCase )
2017 {
2118 JToken result = conformanceCase . run ( ) ;
2219 if ( conformanceCase . error != null )
@@ -77,20 +74,21 @@ public ConformanceCases()
7774
7875 public IEnumerator < object [ ] > GetEnumerator ( )
7976 {
77+ var jsonFetcher = new JsonFetcher ( ) ;
78+ var rootDirectory = "W3C" ;
79+
8080 foreach ( string manifest in manifests )
8181 {
82- JToken manifestJson ;
83-
84- manifestJson = GetJson ( manifest ) ;
82+ JToken manifestJson = jsonFetcher . GetJson ( manifest , rootDirectory ) ;
8583
8684 foreach ( JObject testcase in manifestJson [ "sequence" ] )
8785 {
8886 Func < JToken > run ;
8987 ConformanceCase newCase = new ConformanceCase ( ) ;
9088
91- newCase . input = GetJson ( testcase [ "input" ] ) ;
92- newCase . context = GetJson ( testcase [ "context" ] ) ;
93- newCase . frame = GetJson ( testcase [ "frame" ] ) ;
89+ newCase . input = jsonFetcher . GetJson ( testcase [ "input" ] , rootDirectory ) ;
90+ newCase . context = jsonFetcher . GetJson ( testcase [ "context" ] , rootDirectory ) ;
91+ newCase . frame = jsonFetcher . GetJson ( testcase [ "frame" ] , rootDirectory ) ;
9492
9593 var options = new JsonLdOptions ( "http://json-ld.org/test-suite/tests/" + ( string ) testcase [ "input" ] ) ;
9694
@@ -109,11 +107,11 @@ public IEnumerator<object[]> GetEnumerator()
109107 else if ( testType . Any ( ( s ) => ( string ) s == "jld:FromRDFTest" ) )
110108 {
111109 newCase . input = File . ReadAllText ( Path . Combine ( "W3C" , ( string ) testcase [ "input" ] ) ) ;
112- newCase . output = GetJson ( testcase [ "expect" ] ) ;
110+ newCase . output = jsonFetcher . GetJson ( testcase [ "expect" ] , rootDirectory ) ;
113111 }
114112 else
115113 {
116- newCase . output = GetJson ( testcase [ "expect" ] ) ;
114+ newCase . output = jsonFetcher . GetJson ( testcase [ "expect" ] , rootDirectory ) ;
117115 }
118116 }
119117 else
@@ -138,7 +136,7 @@ public IEnumerator<object[]> GetEnumerator()
138136 }
139137 if ( optionDescription . TryGetValue ( "expandContext" , out value ) )
140138 {
141- newCase . context = GetJson ( testcase [ "option" ] [ "expandContext" ] ) ;
139+ newCase . context = jsonFetcher . GetJson ( testcase [ "option" ] [ "expandContext" ] , rootDirectory ) ;
142140 options . SetExpandContext ( ( JObject ) newCase . context ) ;
143141 }
144142 if ( optionDescription . TryGetValue ( "produceGeneralizedRdf" , out value ) )
@@ -227,32 +225,11 @@ public IEnumerator<object[]> GetEnumerator()
227225
228226 newCase . run = run ;
229227
230- yield return new object [ ] { manifest + ( string ) testcase [ "@id" ] , ( string ) testcase [ "name" ] , newCase } ;
228+ yield return new object [ ] { manifest + ( string ) testcase [ "@id" ] , newCase } ;
231229 }
232230 }
233231 }
234232
235- private JToken GetJson ( JToken j )
236- {
237- try
238- {
239- if ( j == null || j . Type == JTokenType . Null ) return null ;
240- using ( Stream manifestStream = File . OpenRead ( Path . Combine ( "W3C" , ( string ) j ) ) )
241- using ( TextReader reader = new StreamReader ( manifestStream ) )
242- using ( JsonReader jreader = new Newtonsoft . Json . JsonTextReader ( reader )
243- {
244- DateParseHandling = DateParseHandling . None
245- } )
246- {
247- return JToken . ReadFrom ( jreader ) ;
248- }
249- }
250- catch ( Exception e )
251- { // TODO: this should not be here, figure out why this is needed or catch specific exception.
252- return null ;
253- }
254- }
255-
256233 System . Collections . IEnumerator System . Collections . IEnumerable . GetEnumerator ( )
257234 {
258235 throw new Exception ( "auggh" ) ;
0 commit comments