public void testExceptionIsTotalWeightIsNotMatching() { var exceptionThrown = Assert.Throws <Exception>(() => { PathGenericsImpl <Edge, Vertex, Weight> .CreatePathGenerics <Edge, Vertex, Weight>( CreateWeight(16), // SHOULD be 15 ( 3 + 5 + 7 ) and therefore an exception should be thrown new List <Edge> { CreateEdge(CreateVertex("A"), CreateVertex("B"), CreateWeight(3d)), CreateEdge(CreateVertex("B"), CreateVertex("C"), CreateWeight(5d)), CreateEdge(CreateVertex("C"), CreateVertex("D"), CreateWeight(7d)) }, true, // tell creation method to throw exception if sum is not matching false ); }); IsNotNull(exceptionThrown); }
[Test] //@Test(expected = RuntimeException.class) public void testExceptionIsThrownIfVerticesIsNotMatching() { var exceptionThrown = Assert.Throws <Exception>(() => { PathGenericsImpl <Edge, Vertex, Weight> .CreatePathGenerics <Edge, Vertex, Weight>( CreateWeight(15d), new List <Edge> { CreateEdge(CreateVertex("A"), CreateVertex("B"), CreateWeight(3d)), CreateEdge(CreateVertex("B"), CreateVertex("C"), CreateWeight(5d)), // Note that "X" should be "C" below, which is the reason for expected exceotion CreateEdge(CreateVertex("X"), CreateVertex("D"), CreateWeight(7d)) }, false, true // tell creation method to throw exception if not all vertices are matching ); }); IsNotNull(exceptionThrown); }
public override bool Equals(object obj) { if (this == obj) { return(true); } if (obj == null) { return(false); } if (!(obj is PathGenericsImpl <E, V, W>)) { return(false); } PathGenericsImpl <E, V, W> other = (PathGenericsImpl <E, V, W>)obj; if (edges == null) { if (other.edges != null) { return(false); } } else if (!edges.Equals(other.edges)) { return(false); } if (totalWeight == null) { if (other.totalWeight != null) { return(false); } } else if (!totalWeight.Equals(other.totalWeight)) { return(false); } return(true); }