Answered>Order 4298

Suppose we have some method:   public List<Relationship> getRelationships(int id)

The method returns all relationships in an ID’s family, where Relationship is a class with two getters, getParent() and getChild().

In order to test this getRelationships method, we need the ability to verify that all objects in a list of Relationships are connected, without regards to direction. That is, we want to make sure all relationships returned can form edges in one undirected graph.

In essence we want to implement a test-only utility method to help us do testing. We can call it “areAllConnected” and it can accept a list of Relationship.

Of course we should test our testing utility method as well.

Provide test cases. Here is an example: areAllConnected([(1, 2), (2, 3)]) should return true.

Give some description of how to implement this method.

 
"Not answered?"
Get the Answer