-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOSMJSONTest.cs
More file actions
51 lines (43 loc) · 1.28 KB
/
Copy pathOSMJSONTest.cs
File metadata and controls
51 lines (43 loc) · 1.28 KB
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
51
using System.IO;
using JsonDiffPatchDotNet;
using Newtonsoft.Json.Linq;
using OSMJSON.Net.Entities;
using Xunit;
using Xunit.Abstractions;
namespace OSMJSON.Net.Test
{
public class OSMJSONTest
{
private readonly ITestOutputHelper output;
private bool _reserializationTest(string file)
{
var json = File.ReadAllText(file);
var deserialized = OSMJSON.Deserialize(json);
var reserialized = OSMJSON.Serialize(deserialized);
var diff = new JsonDiffPatch();
var a = JToken.Parse(json);
var b = JToken.Parse(reserialized);
var result = diff.Diff(a, b);
if (result != null)
{
output.WriteLine($"Json not equal for file {file}: {result}");
return false;
}
return true;
}
public OSMJSONTest(ITestOutputHelper output)
{
this.output = output;
}
[Fact]
public void DeserializeOSMJSONTest()
{
Assert.True(_reserializationTest("./Fixtures/osmSampleData.json"));
}
[Fact]
public void DeserializeOverpassJSONTest()
{
Assert.True(_reserializationTest("./Fixtures/overpassMixed.json"));
}
}
}