public void TestLoad__IContextualNode() { NodeListMapper mapper2 = new NodeListMapper("SOME_NODE", typeof(DummyIContextualNode)); List <DummyIContextualNode> list = new List <DummyIContextualNode>(); object value = list; ConfigNode node = new TestConfigNode { new TestConfigNode("SOME_NODE") { { "value", "thing1" }, }, new TestConfigNode("SOME_NODE") { { "value", "thing2" }, }, new TestConfigNode("SOME_OTHER_NODE") { { "value", "thing2" }, }, }; OperationContext context = Exemplars.LoadContext; Assert.True(mapper2.Load(ref value, node, context)); Assert.Same(list, value); Assert.Equal(2, list.Count); Assert.Equal("thing1", list[0].value); Assert.Equal("thing2", list[1].value); Assert.Same(context, list[0].lastContext); Assert.Same(context, list[1].lastContext); }
public void TestSave__IContextualNode() { NodeListMapper mapper2 = new NodeListMapper("SOME_NODE", typeof(DummyIContextualNode)); List <DummyIContextualNode> list = new List <DummyIContextualNode> { new DummyIContextualNode { value = "blah1" }, new DummyIContextualNode { value = "blah2" }, }; ConfigNode node = new ConfigNode(); OperationContext context = Exemplars.SaveContext; Assert.True(mapper2.Save(list, node, Exemplars.SaveContext)); ConfigNode expected = new TestConfigNode { new TestConfigNode("SOME_NODE") { { "value", "blah1" }, }, new TestConfigNode("SOME_NODE") { { "value", "blah2" }, } }; AssertUtil.ConfigNodesEqual(expected, node); Assert.Same(context, list[0].lastContext); Assert.Same(context, list[1].lastContext); }
public void TestNew__IContextualNode() { NodeListMapper mapper2 = new NodeListMapper("blah", typeof(DummyIContextualNode)); Assert.Equal("blah", mapper2.name); Assert.Same(typeof(DummyIContextualNode), mapper2.elementType); Assert.Same(typeof(List <DummyIContextualNode>), mapper2.listType); }
public void TestBuildMapper__IContextualNode() { NodeListMapperBuilder builder = new NodeListMapperBuilder("foo", typeof(List <DummyIContextualNode>)); NodeListMapper mapper = Assert.IsType <NodeListMapper>(builder.BuildMapper()); Assert.Equal("foo", mapper.name); Assert.Same(typeof(DummyIContextualNode), mapper.elementType); Assert.Same(typeof(List <DummyIContextualNode>), mapper.listType); }
public void TestBuildMapper__ConfigNode() { NodeListMapperBuilder builder = new NodeListMapperBuilder("foo", typeof(List <ConfigNode>)); NodeListMapper mapper = Assert.IsType <NodeListMapper>(builder.BuildMapper()); Assert.Equal("foo", mapper.name); Assert.Same(typeof(List <ConfigNode>), mapper.listType); Assert.IsType <NodeObjectWrapperConfigNode>(mapper.nodeObjectWrapper);; }
public NodeListMapperTest() { wrapper = Substitute.For <INodeObjectWrapper>(); mapper = new NodeListMapper("SOME_NODE", typeof(object), wrapper); }