public void EdgesComparerTests() { var v11 = new Vertex("A"); var v21 = new Vertex("B"); var v12 = new Vertex("A"); var v22 = new Vertex("B"); var dirEdge1 = new DirectedEdge(v11, v21); var dirEdge2 = new DirectedEdge(v12, v22); var dirEdge3 = new DirectedEdge(v11, v22); var dirEdge4 = new DirectedEdge(v21, v11); var dirEdge5 = new DirectedEdge(v11, v11); var undirEdge1 = new UndirectedEdge(v11, v21); var undirEdge2 = new UndirectedEdge(v12, v22); var undirEdge3 = new UndirectedEdge(v11, v22); var undirEdge4 = new UndirectedEdge(v21, v11); var undirEdge5 = new UndirectedEdge(v11, v11); Assert.IsTrue(dirEdge1.Equals(dirEdge2)); Assert.IsTrue(dirEdge1.Equals(dirEdge3)); Assert.IsTrue(undirEdge1.Equals(undirEdge2)); Assert.IsTrue(undirEdge1.Equals(undirEdge3)); Assert.IsFalse(dirEdge1.Equals(undirEdge1)); Assert.IsFalse(dirEdge1.Equals(dirEdge4)); Assert.IsTrue(undirEdge1.Equals(undirEdge4)); Assert.IsFalse(dirEdge1.Equals(dirEdge5)); Assert.IsFalse(undirEdge1.Equals(undirEdge5)); }
public void Equals() { var edge1 = new UndirectedEdge <int>(1, 2); var edge2 = new UndirectedEdge <int>(1, 2); Assert.AreEqual(edge1, edge1); Assert.AreNotEqual(edge1, edge2); Assert.AreNotEqual(edge2, edge1); Assert.IsFalse(edge1.Equals(edge2)); Assert.IsFalse(edge2.Equals(edge1)); Assert.AreNotEqual(null, edge1); Assert.IsFalse(edge1.Equals(null)); }