Ejemplo n.º 1
0
        /// <summary>
        /// Test removing all neighbor from a list of multiple neighbors
        /// </summary>
        static void TestRemoveAllNeighborsMultipleNeighbors()
        {
            GraphNode <int> node = new GraphNode <int>(4);

            node.AddNeighbor(new GraphNode <int>(5));
            node.AddNeighbor(new GraphNode <int>(6));
            bool success = node.RemoveAllNeighbors();

            Console.Write("TestRemoveAllNeighborsMultipleNeighbors: ");
            string nodeString = node.ToString();

            if (nodeString.Equals("[Node Value: 4 Neighbors: ]") &&
                node.Neighbors.Count == 0 &&
                success)
            {
                Console.WriteLine("Passed");
            }
            else
            {
                Console.WriteLine("FAILED!!! Expected: [Node Value: 4  " +
                                  "Neighbors: ], 0, and true Actual: " + nodeString +
                                  ", " + node.Neighbors.Count + " and " +
                                  success);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Test adding a duplicate neighbor to a list of neighbors
        /// </summary>
        static void TestAddNeighborDuplicateNeighbor()
        {
            GraphNode <int> node          = new GraphNode <int>(4);
            GraphNode <int> duplicateNode = new GraphNode <int>(5);

            node.AddNeighbor(duplicateNode);
            bool success = node.AddNeighbor(duplicateNode);

            Console.Write("TestAddNeighborDuplicateNeighbor: ");
            string nodeString = node.ToString();

            if (nodeString.Equals("[Node Value: 4 Neighbors: 5 ]") &&
                node.Neighbors.Count == 1 &&
                !success)
            {
                Console.WriteLine("Passed");
            }
            else
            {
                Console.WriteLine("FAILED!!! Expected: [Node Value: 4  " +
                                  "Neighbors: 5 ], 1, and false Actual: " + nodeString +
                                  ", " + node.Neighbors.Count + " and " +
                                  success);
            }
        }