public void DFSTest1() { Graph SomeGraph = new Graph(); int[] correctDFS = { 1, 2, 3, 4 }; int[] correctDFS2 = { 1, 3, 4, 2 }; int[] tryDFS = new int[4]; SomeGraph.AddNode(1); SomeGraph.AddNode(2); SomeGraph.AddNode(3); SomeGraph.AddNode(4); SomeGraph.AddEdge(1, 2); SomeGraph.AddEdge(1, 3); SomeGraph.AddEdge(3, 4); int i = 0; foreach (int n in GraphAlgorithms.DFS(SomeGraph, 1)) { tryDFS[i++] = n; } try { CollectionAssert.AreEqual(correctDFS, tryDFS); } catch { CollectionAssert.AreEqual(correctDFS2, tryDFS); } }