|
|
|
|
|
|
var jsonActual = DatasetJsonUtility.ToJToken(o).ToString(); |
|
|
|
Assert.AreEqual(TestHelper.NormalizeJson(jsonExpected), TestHelper.NormalizeJson(jsonActual)); |
|
|
|
} |
|
|
|
|
|
|
|
[Test] |
|
|
|
[TestCase(1,2,3)] |
|
|
|
[TestCase(0,0,0)] |
|
|
|
[TestCase(1000, 13000,700)] |
|
|
|
[TestCase(1.23f, 4.56f, 7.89f)] |
|
|
|
[TestCase(-100, 27.33f, -501.78f)] |
|
|
|
public void Vector3Converter_ConvertsProperly(float x, float y, float z) |
|
|
|
{ |
|
|
|
var converter = new SimulationState.Vector3Converter(); |
|
|
|
var testCase = new Vector3(x,y,z); |
|
|
|
var sb = new StringBuilder(); |
|
|
|
var sw = new StringWriter(sb); |
|
|
|
|
|
|
|
var serializer = JsonSerializer.CreateDefault(); |
|
|
|
|
|
|
|
converter.WriteJson(new JsonTextWriter(sw), testCase, serializer); |
|
|
|
var str = sb.ToString(); |
|
|
|
var sr = new StringReader(str); |
|
|
|
|
|
|
|
var converted = converter.ReadJson(new JsonTextReader(sr), typeof(Vector3), Vector3.zero, false, serializer); |
|
|
|
Assert.AreEqual(testCase, converted); |
|
|
|
} |
|
|
|
|
|
|
|
[Test] |
|
|
|
[TestCase(1,2,3, 4)] |
|
|
|
[TestCase(0,0,0, 1)] |
|
|
|
[TestCase(0, 0.6502878f, 0, -0.7596879f)] |
|
|
|
[TestCase(-0.3670137f, -0.1835069f, 0.1223379f, -0.9036922f)] |
|
|
|
public void QuaternionConverter_ConvertsProperly(float x, float y, float z, float w) |
|
|
|
{ |
|
|
|
var converter = new SimulationState.QuaternionConverter(); |
|
|
|
var testCase = new Quaternion(x, y, z, w); |
|
|
|
var sb = new StringBuilder(); |
|
|
|
var sw = new StringWriter(sb); |
|
|
|
|
|
|
|
var serializer = JsonSerializer.CreateDefault(); |
|
|
|
|
|
|
|
converter.WriteJson(new JsonTextWriter(sw), testCase, serializer); |
|
|
|
var str = sb.ToString(); |
|
|
|
var sr = new StringReader(str); |
|
|
|
|
|
|
|
var converted = converter.ReadJson(new JsonTextReader(sr), typeof(Quaternion), Quaternion.identity, false, serializer); |
|
|
|
Assert.AreEqual(testCase, converted); |
|
|
|
} |
|
|
|
} |
|
|
|
} |