public void TestFromEnum() { var json = "{\"TestDirection\":\"DOWN\"}"; var t = Piekson.FromJson <TestClassWithEnum>(json); Assert.AreEqual(new TestClassWithEnum(TestDirection.DOWN).TestDirection, t.TestDirection); }
public void TestFromType() { var json = "{\"type\":\"TestNamespace.TestClassWithType, Assembly-CSharp-Editor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null\"}"; var t = Piekson.FromJson <TestClassWithType>(json); Assert.AreEqual(typeof(TestClassWithType), t.type); }
public void TestFromNestedJson() { var json = "{\"nested\":{\"test\":100.01}}"; var t = Piekson.FromJson <TestMainClass>(json); Assert.AreEqual(new TestMainClass(new TestNestedClass()), t); }
public void TestNegativeValueFromJson() { var json = "{\"a\":-123,\"b\":\"hel\\\\\\\"lo\",\"d\":-3.14,\"state\":true}"; var t = Piekson.FromJson <TestClass>(json); Assert.AreEqual(new TestClass(-3.14f, true, -123, "hel\\\"lo"), t); }
public void TestFromListInObjectJson() { var json = "{\"names\":[\"Arnold\",\"Marian\",\"Fedrynand\"]}"; var t = Piekson.FromJson <TestNestedCollection>(json); Assert.AreEqual(new TestNestedCollection(new List <string> { "Arnold", "Marian", "Fedrynand" }), t); }
public void TestFromObjectInListJson() { var json = "[{\"test\":1},{\"test\":2}]"; var t = Piekson.FromJson <List <TestSimpleClass> >(json); Assert.AreEqual(new List <TestSimpleClass> { new TestSimpleClass(1), new TestSimpleClass(2) }, t); }
public void TestFromStringListJson() { var json = "[\"a\",\"b\",\"c\",\"d\"]"; var t = Piekson.FromJson <List <string> >(json); Assert.AreEqual(new List <string> { "a", "b", "c", "d" }, t); }
public void TestFromIntListJson() { var json = "[1,2,3,4,5,6]"; var t = Piekson.FromJson <List <int> >(json); Assert.AreEqual(new List <int> { 1, 2, 3, 4, 5, 6 }, t); }
public void TestFromDictionaryInObjectJson() { var json = "{\"test\":{\"a\":1, \"b\":3}}"; var t = Piekson.FromJson <TestDictionaryInObject>(json); CollectionAssert.AreEquivalent(new Dictionary <string, int>() { { "a", 1 }, { "b", 3 } }, t.test); }
public void TestFromDictionaryJson() { var json = "{\"a\":1,\"b\":2,\"c\":3,\"d\":4}"; var t = Piekson.FromJson <Dictionary <string, int> >(json); CollectionAssert.AreEquivalent(new Dictionary <string, int>() { { "a", 1 }, { "b", 2 }, { "c", 3 }, { "d", 4 }, }, t); }
public void TestFromObjectInDictionaryJson() { var json = "{\"testObj1\":{\"test\":1}, \"testObj2\":{\"test\":2}}"; var t = Piekson.FromJson <Dictionary <string, TestSimpleClass> >(json); CollectionAssert.AreEquivalent( new Dictionary <string, TestSimpleClass>() { { "testObj1", new TestSimpleClass(1) }, { "testObj2", new TestSimpleClass(2) } }, t); }
void Awake() { var levelData = Piekson.FromJson <LevelDto>(Level.Json); spawnSprites(levelData); spawnSpriteShapes(levelData); var carWasSpawned = spawnPrefabs(levelData); if (carWasSpawned) { SEventSystem.FireEvent(EventNames.LEVEL_INSTANTIATED); } else { Debug.Log("Car was not instantiated!"); } }