Esempio n. 1
0
    public void LoadUtils_SetParentDefaults_LoadParentedTwice()
    {
        var doc = FromString(@"
            default:
                intKey: 0
                stringKey: a
            basic:
                basedOn: default
                intKey: 1
            ");

        Dictionary <string, TestClass> d = null;

        LoadUtils.SetParentDefaults(ref d, doc, TestClass.getBasedOn);
        var doc2 = FromString(@"
            default:
                intKey: 1
                stringKey: b
            basic:
                basedOn: default
            ");

        LoadUtils.SetParentDefaults(ref d, doc2, TestClass.getBasedOn);
        Assert.AreEqual(2, d.Count);
        Assert.AreEqual(1, d["basic"].intKey.Value);
        Assert.AreEqual("b", d["basic"].stringKey);
    }
Esempio n. 2
0
    public void LoadUtils_SetParentDefaults_LoadSimple()
    {
        var doc = FromString(@"
            basic:
                intKey: 1
                stringKey: 2
            ");

        Dictionary <string, TestClass> d = null;

        LoadUtils.SetParentDefaults(ref d, doc, TestClass.getBasedOn);
        Assert.AreEqual(1, d.Count);
        Assert.AreEqual(1, d["basic"].intKey.Value);
        Assert.AreEqual("2", d["basic"].stringKey);
    }
Esempio n. 3
0
    public void LoadUtils_SetParentDefaults_IgnoreFields()
    {
        var doc = FromString(@"
            default:
                intKey: 0
                stringKey: a
            basic:
                basedOn: default
            ");

        Dictionary <string, TestClass> d = null;

        LoadUtils.SetParentDefaults(ref d, doc, TestClass.getBasedOn,
                                    new string[] { "basedOn", "intKey" });
        Assert.AreEqual(null, d["basic"].intKey);
        Assert.AreEqual("a", d["basic"].stringKey);
    }
Esempio n. 4
0
    public void LoadUtils_SetParentDefaults_LoadNullableRecursive()
    {
        var doc = FromString(@"
            default:
                intKey: 0
                stringKey: a
            basic:
                basedOn: default
                stringKey: basicString
            deeper:
                basedOn: basic
                stringKey: deeperString
            ");

        Dictionary <string, TestClass> d = null;

        LoadUtils.SetParentDefaults(ref d, doc, TestClass.getBasedOn);
        Assert.AreEqual(3, d.Count);
        Assert.AreEqual(0, d["deeper"].intKey.Value);
        Assert.AreEqual("deeperString", d["deeper"].stringKey);
    }