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); }