示例#1
0
 public void Setup()
 {
     graph = new Graph(new int[,] {
         { 0, 0, 0 },
         { 0, 0, 1 }, // Obstacle still part of adjacencyList
         { 0, 0, 0 }
     });
     node = graph.nodes[graph.nodes.Length / 2];
 }
示例#2
0
 public void Setup()
 {
     grid = new int[,] {
         { 1, 1, 0, 1, 0 },
         { 0, 1, 0, 1, 1 },
         { 1, 1, 0, 0, 0 },
         { 0, 0, 0, 0, 0 },
         { 1, 1, 1, 0, 0 }
     };
     graph = new Graph(grid);
 }
示例#3
0
        public void UpdateGraphOnDragStop()
        {
            Graph graph = new Graph(new int[,] {
                { 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0 }
            });
            Graph expectedGraph = new Graph(new int[,] {
                { 0, 0, 0, 0, 0 },
                { 0, 1, 1, 1, 0 },
                { 0, 1, 1, 1, 0 },
                { 0, 1, 1, 1, 0 },
                { 0, 0, 0, 0, 0 }
            });

            // User Drag and Drop Event

            CollectionAssert.AreEqual(expectedGraph.nodes, graph.nodes);
        }
示例#4
0
        public void UpdateGraphObstacles()
        {
            Graph graph = new Graph(new int[,] {
                { 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0 }
            });
            Graph expectedGraph = new Graph(new int[,] {
                { 0, 0, 0, 0, 0 },
                { 0, 1, 1, 1, 0 },
                { 0, 1, 1, 1, 0 },
                { 0, 1, 1, 1, 0 },
                { 0, 0, 0, 0, 0 }
            });

            Search search = new Search(graph);
            search.Start(graph.nodes[0], graph.nodes[12]);
            while (!search.finished)
            {
                search.Step();
            }

            // User Drag and Drop Event
            Assert.AreEqual<Graph>(graph.Update(), expectedGraph);

            CollectionAssert.AreEqual(expectedGraph.nodes, graph.nodes);

            // If assertion passes without re-instantiating, graph is passed as reference (which is preferred)
            //search = new Search(graph);

            // Verify that center node is now unreachable
            search.Start(graph.nodes[0], graph.nodes[12]);
            while(!search.finished)
            {
                search.Step();
            }
            Assert.AreEqual(0, search.path.Count);
        }
示例#5
0
 public Search(Graph g)
 {
     graph = g;
 }
示例#6
0
 public void Setup()
 {
     int[,] nodes = new int[,] {
         { 1, 1, 0, 1, 0 },
         { 0, 1, 0, 1, 1 },
         { 1, 1, 0, 0, 0 },
         { 0, 0, 0, 0, 0 },
         { 1, 1, 1, 0, 0 }
     };
     graph = new Graph(nodes);
     search = new Search(graph);
 }