public void Add_Returns_Parent_Expression() { var graph = MockRepository.GenerateMock<IGraph>(); var graphExpression = new GraphExpression<IGraph>(graph); var expression = new NodeCollectionModifiersExpression<IGraphExpression>(graph, graphExpression); var instance = expression.Add(nodes => nodes.WithName("a")); Assert.AreSame(instance, graphExpression); }
public void Add_Gets_Applied_To_Graph() { var graph = MockRepository.GenerateMock<IGraph>(); graph.Expect(x => x.AddNode(null)) .IgnoreArguments() .Constraints(Is.Matching<IGraphNode>(x => x.Name == "a")); graph.Expect(x => x.AddNode(null)) .IgnoreArguments() .Constraints(Is.Matching<IGraphNode>(x => x.Name == "b")); var graphExpression = new GraphExpression<IGraph>(graph); var expression = new NodeCollectionModifiersExpression<IGraphExpression>(graph, graphExpression); expression.Add( nodes => { nodes.WithName("a"); nodes.WithName("b"); } ); graph.VerifyAllExpectations(); }