public void SigmaGraphJsonConstructor_WithValidInput_ParsesJson()
        {
            string     json  = SigmaGraphFactory.GetValidSigmaGraphJson();
            SigmaGraph graph = new SigmaGraph(json);

            Assert.IsTrue(graph.nodes.Count == 2);
            Assert.IsTrue(graph.edges.Count == 1);
        }
예제 #2
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"));
        }
예제 #3
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);
            }
        }
 public void SigmaGraphJsonConstructor_WithInvalidInput_ThrowsJsonError()
 {
     string     json  = "bob";
     SigmaGraph graph = new SigmaGraph(json);
 }