Exemple #1
0
        /// <summary>
        /// Saves the dgml graph to given file path
        /// </summary>
        /// <param name="filePath"></param>
        public static void Save(string filePath)
        {
            Graph g = new Graph()
            {
                Nodes = Nodes.ToArray(),
                Links = Links.ToArray(),
            };

            g.Save(filePath);
        }
Exemple #2
0
        public void TestSave_CategoriesDgml()
        {
            Node first = new Node("1", "first", "number");
            Node second = new Node("2", "second");
            Link link = new Link("1", "2", "connects", "link");
            Category[] categories =
            {
                new Category("number", "Green"),
                new Category("link", stroke: "Black", basedOn: "number"),
            };

            Graph graph = new Graph()
            {
                Nodes = new[] { first, second },
                Links = new[] { link },
                Categories = categories,
            };

            string actualDgml = graph.ToDgml();

            MatchDgml(CategoriesDgml, actualDgml);
        }
        private void MatchGraph(IDictionary<string, ICollection<string>> expectedGraph, Graph actualGraph)
        {
            Assert.AreEqual(expectedGraph.Keys.Count, actualGraph.Nodes.Length);
            Assert.AreEqual(expectedGraph.Values.SelectMany(v => v).Count(), actualGraph.Links.Length);

            foreach (string nodeName in expectedGraph.Keys)
            {
                Assert.IsNotNull(actualGraph.Nodes.Single(n => n.Id == nodeName));
                foreach (string link in expectedGraph[nodeName])
                {
                    Assert.IsNotNull(actualGraph.Links.Single(node => node.Source == nodeName && node.Target == link));
                }
            }
        }
Exemple #4
0
        public void TestSave_StyledDgml()
        {
            Node first = new Node("1", "first", "category");
            Node second = new Node("2", "second");
            Link link = new Link("1", "2", "connects");
            Style style = new Style("category", "#FF000000");

            Graph graph = new Graph()
            {
                Nodes = new[] { first, second },
                Links = new[] { link },
                Styles = new[] { style },
            };

            string actualDgml = graph.ToDgml();

            MatchDgml(StyledDgml, actualDgml);
        }
Exemple #5
0
        public void TestSave_EmptyDgml()
        {
            Graph graph = new Graph();
            string actualDgml = graph.ToDgml();

            MatchDgml(EmptyDgml, actualDgml);
        }
Exemple #6
0
        public void TestSave_ValidDgml()
        {
            Node first = new Node("1", "first");
            Node second = new Node("2", "second");
            Link link = new Link("1", "2", "connects");

            Graph graph = new Graph()
            {
                Nodes = new[] { first, second },
                Links = new[] { link },
            };

            string actualDgml = graph.ToDgml();

            MatchDgml(ValidDgml, actualDgml);
        }