public void DoesNotFindNonExistingNodes() { EdgeListGraph <int> graph = new EdgeListGraph <int>(); EdgeListNode <int> node1 = new EdgeListNode <int>(1); EdgeListNode <int> node2 = new EdgeListNode <int>(2); EdgeListNode <int> node3 = new EdgeListNode <int>(3); node2.AddEdgeTo(node3); graph.AddNode(node1); graph.AddNode(node2); EdgeListNode <int> result; //by value result = graph.FindNode(12); Assert.Null(result); //by node result = graph.FindNode(new EdgeListNode <int>(12)); Assert.Null(result); //by predicate result = graph.FindNode(node => node.Value >= 12); Assert.Null(result); }
public void FindsExistingNodes() { EdgeListGraph <int> graph = new EdgeListGraph <int>(); EdgeListNode <int> node1 = new EdgeListNode <int>(1); EdgeListNode <int> node2 = new EdgeListNode <int>(2); EdgeListNode <int> node3 = new EdgeListNode <int>(3); node2.AddEdgeTo(node3); graph.AddNode(node1); graph.AddNode(node2); EdgeListNode <int> result1, result2, result3; //by value result1 = graph.FindNode(1); result2 = graph.FindNode(2); result3 = graph.FindNode(3); Assert.NotNull(result1); Assert.NotNull(result2); Assert.NotNull(result3); //by node result1 = graph.FindNode(node1); result2 = graph.FindNode(node2); result3 = graph.FindNode(node3); Assert.NotNull(result1); Assert.NotNull(result2); Assert.NotNull(result3); //by predicate result1 = graph.FindNode(node => node.Value < 2); result2 = graph.FindNode(node => Math.Pow(node.Value, 2) == 4); result3 = graph.FindNode(node => node.Value > 2); Assert.NotNull(result1); Assert.NotNull(result2); Assert.NotNull(result3); }