Esempio n. 1
0
    public void TestFromEnum()
    {
        var json = "{\"TestDirection\":\"DOWN\"}";
        var t    = Piekson.FromJson <TestClassWithEnum>(json);

        Assert.AreEqual(new TestClassWithEnum(TestDirection.DOWN).TestDirection, t.TestDirection);
    }
Esempio n. 2
0
    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);
    }
Esempio n. 3
0
    public void TestFromNestedJson()
    {
        var json = "{\"nested\":{\"test\":100.01}}";
        var t    = Piekson.FromJson <TestMainClass>(json);

        Assert.AreEqual(new TestMainClass(new TestNestedClass()), t);
    }
Esempio n. 4
0
    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);
    }
Esempio n. 5
0
    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);
    }
Esempio n. 6
0
    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);
    }
Esempio n. 7
0
    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);
    }
Esempio n. 8
0
    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);
    }
Esempio n. 9
0
    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);
    }
Esempio n. 10
0
    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);
    }
Esempio n. 11
0
    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);
    }
Esempio n. 12
0
    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!");
        }
    }