コード例 #1
0
        public void TestAddingMultipleNodesRaisesCollectionChangedEvent()
        {
            bool eventFired = false;
            NotifyCollectionChangedAction action = NotifyCollectionChangedAction.Reset;
            GraphData   g     = new GraphData("scope");
            Node        node1 = new Node("Node1");
            Node        node2 = new Node("Node2");
            Node        node3 = new Node("Node3");
            List <Node> nodes = new List <Node>
            {
                node1,
                node2,
                node3
            };

            g.CollectionChanged += (sender, e) =>
            {
                action     = e.Action;
                eventFired = true;
            };

            EnqueueCallback(() => g.AddNodes(nodes));
            EnqueueConditional(() => eventFired);

            EnqueueCallback(() => Assert.AreEqual(nodes.Count, g.Count));
            EnqueueCallback(() => Assert.IsTrue(g.ContainsNode(node1)));
            EnqueueCallback(() => Assert.IsTrue(g.ContainsNode(node2)));
            EnqueueCallback(() => Assert.IsTrue(g.ContainsNode(node3)));
            EnqueueCallback(() => Assert.AreEqual <NotifyCollectionChangedAction>(NotifyCollectionChangedAction.Add, action));
            EnqueueTestComplete();
        }
コード例 #2
0
ファイル: GraphGenerator.cs プロジェクト: senfo/snaglV2
        /// <summary>
        /// 
        /// </summary>
        /// <param name="numberOfNodes"></param>
        /// <param name="numberOfEdges"></param>
        /// <returns></returns>
        public GraphData GenerateGraph(string scope, int numberOfNodes, int numberOfEdges)
        {
            generatedGraph = new GraphData(scope);

            List<Node> nodes = GenerateNodes(numberOfNodes);
            List<IEdge> edges = GenerateEdges(numberOfEdges, nodes);

            generatedGraph.AddNodes(nodes);
            generatedGraph.AddEdges(edges);

            return generatedGraph;
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="numberOfNodes"></param>
        /// <param name="numberOfEdges"></param>
        /// <returns></returns>
        public GraphData GenerateGraph(string scope, int numberOfNodes, int numberOfEdges)
        {
            generatedGraph = new GraphData(scope);

            List <Node>  nodes = GenerateNodes(numberOfNodes);
            List <IEdge> edges = GenerateEdges(numberOfEdges, nodes);

            generatedGraph.AddNodes(nodes);
            generatedGraph.AddEdges(edges);

            return(generatedGraph);
        }
コード例 #4
0
        public void TestAddingMultipleNodes()
        {
            GraphData   g     = new GraphData("scope");
            Node        node1 = new Node("Node1");
            Node        node2 = new Node("Node2");
            Node        node3 = new Node("Node3");
            List <Node> nodes = new List <Node>
            {
                node1,
                node2,
                node3
            };

            g.AddNodes(nodes);

            Assert.AreEqual(nodes.Count, g.Count);
            Assert.IsTrue(g.ContainsNode(node1));
            Assert.IsTrue(g.ContainsNode(node2));
            Assert.IsTrue(g.ContainsNode(node3));
        }
コード例 #5
0
        public void TestRemoveMultipleNodes()
        {
            GraphData   g     = new GraphData("scope");
            Node        node1 = new Node("Node1");
            Node        node2 = new Node("Node2");
            Node        node3 = new Node("Node3");
            Node        node4 = new Node("Node4");
            List <Node> nodes = new List <Node>
            {
                node1,
                node2,
                node3
            };

            g.AddNodes(nodes);
            g.AddNode(node4);
            g.RemoveNodes(nodes);

            Assert.AreEqual(1, g.Count);
            Assert.IsTrue(g.ContainsNode(node4));
        }
コード例 #6
0
ファイル: GraphDataTests.cs プロジェクト: senfo/snaglV2
        public void TestRemoveMultipleNodes()
        {
            GraphData g = new GraphData("scope");
            Node node1 = new Node("Node1");
            Node node2 = new Node("Node2");
            Node node3 = new Node("Node3");
            Node node4 = new Node("Node4");
            List<Node> nodes = new List<Node>
            {
                node1,
                node2,
                node3
            };

            g.AddNodes(nodes);
            g.AddNode(node4);
            g.RemoveNodes(nodes);

            Assert.AreEqual(1, g.Count);
            Assert.IsTrue(g.ContainsNode(node4));
        }
コード例 #7
0
ファイル: GraphDataTests.cs プロジェクト: senfo/snaglV2
        public void TestAddingMultipleNodesRaisesCollectionChangedEvent()
        {
            bool eventFired = false;
            NotifyCollectionChangedAction action = NotifyCollectionChangedAction.Reset;
            GraphData g = new GraphData("scope");
            Node node1 = new Node("Node1");
            Node node2 = new Node("Node2");
            Node node3 = new Node("Node3");
            List<Node> nodes = new List<Node>
            {
                node1,
                node2,
                node3
            };

            g.CollectionChanged += (sender, e) =>
            {
                action = e.Action;
                eventFired = true;
            };

            EnqueueCallback(() => g.AddNodes(nodes));
            EnqueueConditional(() => eventFired);

            EnqueueCallback(() => Assert.AreEqual(nodes.Count, g.Count));
            EnqueueCallback(() => Assert.IsTrue(g.ContainsNode(node1)));
            EnqueueCallback(() => Assert.IsTrue(g.ContainsNode(node2)));
            EnqueueCallback(() => Assert.IsTrue(g.ContainsNode(node3)));
            EnqueueCallback(() => Assert.AreEqual<NotifyCollectionChangedAction>(NotifyCollectionChangedAction.Add, action));
            EnqueueTestComplete();
        }
コード例 #8
0
ファイル: GraphDataTests.cs プロジェクト: senfo/snaglV2
        public void TestAddingMultipleNodes()
        {
            GraphData g = new GraphData("scope");
            Node node1 = new Node("Node1");
            Node node2 = new Node("Node2");
            Node node3 = new Node("Node3");
            List<Node> nodes = new List<Node>
            {
                node1,
                node2,
                node3
            };

            g.AddNodes(nodes);

            Assert.AreEqual(nodes.Count, g.Count);
            Assert.IsTrue(g.ContainsNode(node1));
            Assert.IsTrue(g.ContainsNode(node2));
            Assert.IsTrue(g.ContainsNode(node3));
        }