Пример #1
0
        public async Task Can_Roundtrip_Serialize_To_Json()
        {
            // Assemble
            HardCodedNavigationTreeBuilder builder  = new HardCodedNavigationTreeBuilder();
            TreeNode <NavigationNode>      rootNode = await builder.GetTree();

            //Act
            string json = rootNode.ToJsonIndented();

            //NavigationTreeJsonConverter treeConverter = new NavigationTreeJsonConverter();

            //TreeNode<NavigationNode> roundTripNode = builder.BuildTreeFromJson(json);

            //string json2 = roundTripNode.ToJsonIndented();

            //using (StreamWriter stream = File.CreateText("dumpjson-roundtrip.txt"))
            //{
            //    stream.WriteLine(json2);
            //}

            //Assert

            //Assert.True(roundTripNode != null);

            //// currently fails
            //Assert.True(roundTripNode.Children.Count > 2);
        }
Пример #2
0
        public async Task Can_Serialize_To_Json()
        {
            // Assemble
            HardCodedNavigationTreeBuilder builder       = new HardCodedNavigationTreeBuilder();
            NavigationTreeJsonConverter    jsonConverter = new NavigationTreeJsonConverter();

            //Act
            TreeNode <NavigationNode> rootNode = await builder.GetTree();

            string json = jsonConverter.ConvertToJsonIndented(rootNode);



            //Assert
            Assert.True(!string.IsNullOrEmpty(json));

            //using (StreamWriter stream = File.CreateText("dumpjson.txt"))
            //{
            //    stream.WriteLine(json);
            //}

            //System.Console.WriteLine(json);

            //output.WriteLine(json);
        }
Пример #3
0
        public async Task Can_Roundtrip_Serialize_To_Xml()
        {
            // Assemble
            HardCodedNavigationTreeBuilder builder  = new HardCodedNavigationTreeBuilder();
            TreeNode <NavigationNode>      rootNode = await builder.GetTree();

            NavigationTreeXmlConverter converter = new NavigationTreeXmlConverter();

            //Act
            string xml = converter.ToXmlString(rootNode);

            Assert.True(xml.Length > 10);

            //using (StreamWriter stream = File.CreateText("dumpxml.txt"))
            //{
            //    stream.WriteLine(xml);
            //}
        }