public void TestTestConfigNode() { ConfigNode node = new TestConfigNode("NODE") { { "value1", "something" }, { "value2", "something else" }, { "multiple", "first" }, { "multiple", "second" }, new ConfigNode.Value("foo", "bar"), { "NODE_1", new TestConfigNode { { "name", "something" }, { "stuff", "something else" }, } }, new TestConfigNode("MULTIPLE") { { "value3", "blah" }, { "value4", "bleh" }, }, new TestConfigNode("MULTIPLE") { { "value3", "blih" }, { "value4", "bloh" }, }, }; Assert.Equal("something", node.GetValue("value1")); Assert.Equal("something else", node.GetValue("value2")); Assert.Equal(new[] { "first", "second" }, node.GetValues("multiple")); Assert.Equal("bar", node.GetValue("foo")); ConfigNode innerNode1 = node.GetNode("NODE_1"); Assert.NotNull(innerNode1); Assert.Equal("NODE_1", innerNode1.name); Assert.Equal("something", innerNode1.GetValue("name")); Assert.Equal("something else", innerNode1.GetValue("stuff")); ConfigNode[] innerNodes2 = node.GetNodes("MULTIPLE"); Assert.NotNull(innerNodes2); Assert.Equal(2, innerNodes2.Length); ConfigNode innerNode2a = innerNodes2[0]; Assert.NotNull(innerNode2a); Assert.Equal("blah", innerNode2a.GetValue("value3")); Assert.Equal("bleh", innerNode2a.GetValue("value4")); ConfigNode innerNode2b = innerNodes2[1]; Assert.NotNull(innerNode2b); Assert.Equal("blih", innerNode2b.GetValue("value3")); Assert.Equal("bloh", innerNode2b.GetValue("value4")); }
public void TestSave__Empty() { List <string> value = new List <string>(); ConfigNode node = new TestConfigNode { { "someValue", "blah0" }, }; Assert.False(mapper.Save(value, node, Exemplars.SaveContext)); Assert.Equal(new[] { "blah0" }, node.GetValues("someValue")); Assert.Empty(value); }
public void TestSave__ExistingValue() { List <string> list = new List <string> { "blah1", "blah2" }; ConfigNode node = new TestConfigNode { { "someValue", "blah0" }, }; Assert.True(mapper.Save(list, node, Exemplars.SaveContext)); Assert.Equal(new[] { "blah0", "$$blah1$$", "$$blah2$$" }, node.GetValues("someValue")); Assert.Equal(new[] { "blah1", "blah2" }, list.ToArray()); }