1
1
using System ;
2
2
using System . Collections . Generic ;
3
3
using System . Linq ;
4
- using System . Text ;
5
4
6
5
using Newtonsoft . Json . Linq ;
7
6
using Xunit ;
8
- using Xunit . Extensions ;
9
7
using System . IO ;
10
- using Newtonsoft . Json ;
11
8
using JsonLD . Core ;
12
9
using JsonLD . Util ;
13
10
@@ -16,7 +13,7 @@ namespace JsonLD.Test
16
13
public class ConformanceTests
17
14
{
18
15
[ Theory , ClassData ( typeof ( ConformanceCases ) ) ]
19
- public void ConformanceTestPasses ( string id , string testname , ConformanceCase conformanceCase )
16
+ public void ConformanceTestPasses ( string id , ConformanceCase conformanceCase )
20
17
{
21
18
JToken result = conformanceCase . run ( ) ;
22
19
if ( conformanceCase . error != null )
@@ -77,20 +74,21 @@ public ConformanceCases()
77
74
78
75
public IEnumerator < object [ ] > GetEnumerator ( )
79
76
{
77
+ var jsonFetcher = new JsonFetcher ( ) ;
78
+ var rootDirectory = "W3C" ;
79
+
80
80
foreach ( string manifest in manifests )
81
81
{
82
- JToken manifestJson ;
83
-
84
- manifestJson = GetJson ( manifest ) ;
82
+ JToken manifestJson = jsonFetcher . GetJson ( manifest , rootDirectory ) ;
85
83
86
84
foreach ( JObject testcase in manifestJson [ "sequence" ] )
87
85
{
88
86
Func < JToken > run ;
89
87
ConformanceCase newCase = new ConformanceCase ( ) ;
90
88
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 ) ;
94
92
95
93
var options = new JsonLdOptions ( "http://json-ld.org/test-suite/tests/" + ( string ) testcase [ "input" ] ) ;
96
94
@@ -109,11 +107,11 @@ public IEnumerator<object[]> GetEnumerator()
109
107
else if ( testType . Any ( ( s ) => ( string ) s == "jld:FromRDFTest" ) )
110
108
{
111
109
newCase . input = File . ReadAllText ( Path . Combine ( "W3C" , ( string ) testcase [ "input" ] ) ) ;
112
- newCase . output = GetJson ( testcase [ "expect" ] ) ;
110
+ newCase . output = jsonFetcher . GetJson ( testcase [ "expect" ] , rootDirectory ) ;
113
111
}
114
112
else
115
113
{
116
- newCase . output = GetJson ( testcase [ "expect" ] ) ;
114
+ newCase . output = jsonFetcher . GetJson ( testcase [ "expect" ] , rootDirectory ) ;
117
115
}
118
116
}
119
117
else
@@ -138,7 +136,7 @@ public IEnumerator<object[]> GetEnumerator()
138
136
}
139
137
if ( optionDescription . TryGetValue ( "expandContext" , out value ) )
140
138
{
141
- newCase . context = GetJson ( testcase [ "option" ] [ "expandContext" ] ) ;
139
+ newCase . context = jsonFetcher . GetJson ( testcase [ "option" ] [ "expandContext" ] , rootDirectory ) ;
142
140
options . SetExpandContext ( ( JObject ) newCase . context ) ;
143
141
}
144
142
if ( optionDescription . TryGetValue ( "produceGeneralizedRdf" , out value ) )
@@ -227,32 +225,11 @@ public IEnumerator<object[]> GetEnumerator()
227
225
228
226
newCase . run = run ;
229
227
230
- yield return new object [ ] { manifest + ( string ) testcase [ "@id" ] , ( string ) testcase [ "name" ] , newCase } ;
228
+ yield return new object [ ] { manifest + ( string ) testcase [ "@id" ] , newCase } ;
231
229
}
232
230
}
233
231
}
234
232
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
-
256
233
System . Collections . IEnumerator System . Collections . IEnumerable . GetEnumerator ( )
257
234
{
258
235
throw new Exception ( "auggh" ) ;
0 commit comments