public Graph GraphExpression(GraphExpression node, List <Object> parameters) { Set vertices = _interpreter.DispatchSet(node.Vertices, parameters); Set edges = _interpreter.DispatchSet(node.Edges, parameters); Function src = _interpreter.DispatchFunction(node.Src, parameters); Function dst = _interpreter.DispatchFunction(node.Dst, parameters); return(new Graph(vertices, edges, src, dst)); }
public void GraphExpression_ValidExpressions_ReturnsCorrectGraph() { IInterpreterGraph parent = Substitute.For <IInterpreterGraph>(); GraphHelper graphHelper = SetUpHelper(parent); SetExpression verticesExpr = new SetExpression(null, null, null, 1, 1); SetExpression edgesExpr = new SetExpression(null, null, null, 1, 1); IdentifierExpression srcExpr = new IdentifierExpression(null, 1, 1); IdentifierExpression dstExpr = new IdentifierExpression(null, 1, 1); GraphExpression graphExpr = new GraphExpression(verticesExpr, edgesExpr, srcExpr, dstExpr, 1, 1); Set expectedVerticesSet = new Set(); Set expectedEdgesSet = new Set(); Function expectedSrcFunc = new Function(42); Function expectedDstFunc = new Function(43); Graph expected = new Graph(expectedVerticesSet, expectedEdgesSet, expectedSrcFunc, expectedDstFunc); parent.DispatchSet(verticesExpr, Arg.Any <List <Object> >()).Returns(expectedVerticesSet); parent.DispatchSet(edgesExpr, Arg.Any <List <Object> >()).Returns(expectedEdgesSet); parent.DispatchFunction(srcExpr, Arg.Any <List <Object> >()).Returns(expectedSrcFunc); parent.DispatchFunction(dstExpr, Arg.Any <List <Object> >()).Returns(expectedDstFunc); Graph result = graphHelper.GraphExpression(graphExpr, new List <Object>()); result.Should().BeEquivalentTo(expected); }