Exemple #1
0
        public void ToSigmaJson_WithValidInput_CreatesValidGraph()
        {
            var tree = TreeFactory.CreateValidRBT();
            TreeToJsonConverter converter = new TreeToJsonConverter();

            var graph = new SigmaGraph(converter.ToSigmaJson(tree));

            Assert.IsTrue(graph.edges.Count == 4);
            Assert.IsTrue(graph.edges.Any(x => x.source == "0" && x.target == "1"));
            Assert.IsTrue(graph.edges.Any(x => x.source == "0" && x.target == "2"));
            Assert.IsTrue(graph.edges.Any(x => x.source == "1" && x.target == "3"));
            Assert.IsTrue(graph.edges.Any(x => x.source == "1" && x.target == "4"));
        }
Exemple #2
0
        public void ConvertToTree_InvertsToSigmaJson()
        {
            var tree = TreeFactory.CreateValidRBT();
            TreeToJsonConverter converter = new TreeToJsonConverter();
            var graph      = new SigmaGraph(converter.ToSigmaJson(tree));
            var treeParsed = converter.ConvertToTree(graph);

            Assert.AreEqual(tree.Root.Value, treeParsed.Root.Value);
            Assert.AreEqual(tree.Root.id, treeParsed.Root.id);


            foreach (var node in tree)
            {
                var nodeParsed = treeParsed.FindNode(node.id);
                Assert.AreEqual(node.Value, nodeParsed.Value);
            }
        }