public void BellmanFordShortestPath() { var run = new MoveTypeEdgeData { moveType = MoveType.Run }; var jump = new MoveTypeEdgeData { moveType = MoveType.Jump }; var wallJump = new MoveTypeEdgeData { moveType = MoveType.WallJump }; var myGraph = new UndirectedWeightedGraph <char, MoveTypeEdgeData>(); myGraph.AddNodes('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'); myGraph.AddEdges( ('a', 'b', 2, run), ('a', 'c', 3, run), ('a', 'e', 4, wallJump), ('b', 'd', 2, jump), ('b', 'e', 1, run), ('c', 'g', 4, jump), ('c', 'h', 11, run), ('d', 'c', 3, jump), ('d', 'f', 2, run), ('d', 'h', 3, wallJump), ('e', 'f', 5, run), ('f', 'h', 6, wallJump), ('g', 'h', 7, run) ); myGraph .BellmanFordShortestPath('a', 'h') .Select(pair => myGraph.EdgeData(pair.Item1, pair.Item2)) .Should() .ContainInOrder( run, jump, wallJump ) .And .HaveCount(3); // have to call Count() because otherwise the lazy evaluation wont trigger myGraph.Invoking(x => x.BellmanFordShortestPath('a', 'z').Count()).Should().Throw <System.ArgumentException>(); }