-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathJsonTestCase.cs
50 lines (36 loc) · 1.95 KB
/
JsonTestCase.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.Collections.Generic;
namespace JsonLD.Infrastructure.Text.Tests
{
internal class JsonTestCase
{
private readonly string _dataPath;
private readonly bool _isRemoteDocumentTest;
internal JsonTestCase(Dictionary<string, object> dictionary, string dataPath, bool isRemoteDocumentTest)
{
Id = dictionary.Required<string>("@id");
Type = dictionary.Optional<List<string>>("@type");
Input = dictionary.Required<string>("input");
Expect = dictionary.Required<string>("expect");
Context = dictionary.Optional<string>("context");
Frame = dictionary.Optional<string>("frame");
var options = dictionary.Optional<Dictionary<string, object>>("option");
if (options != null) Options = new JsonTestCaseOptions(options);
_dataPath = dataPath;
_isRemoteDocumentTest = isRemoteDocumentTest;
}
internal string Context { get; }
internal string Expect { get; }
internal string Frame { get; }
internal string Id { get; }
internal string Input { get; }
internal JsonTestCaseOptions Options { get; }
internal IEnumerable<string> Type { get; }
internal string GetContextJson() => Context == null ? null : JsonFetcher.GetJsonAsString(_dataPath, Context);
internal string GetExpandContextJson() => Options?.ExpandContext == null ? null : JsonFetcher.GetJsonAsString(_dataPath, Options.ExpandContext);
internal string GetExpectJson() => Expect == null ? null : JsonFetcher.GetJsonAsString(_dataPath, Expect);
internal string GetFrameJson() => Frame == null ? null : JsonFetcher.GetJsonAsString(_dataPath, Frame);
internal string GetInputJson() => _isRemoteDocumentTest
? JsonFetcher.GetRemoteJsonAsString(Input)
: JsonFetcher.GetJsonAsString(_dataPath, Input);
}
}