public void DelegateFlowArrives() { var testModel = new IntFlowModel(); var source = new IntFlowSource(); var del = new IntFlowDelegate(); var sink = new IntFlowSink(); testModel.Components = new IntFlowComponentCollection(source, del, sink); source.SendForward = testModel.CreateForward; source.ReceivedBackward = testModel.PrintReceivedBackward; sink.SendBackward = testModel.CreateBackward; sink.ReceivedForward = testModel.PrintReceivedForward; testModel.Combinator.ConnectOutWithIn(source, del); testModel.Combinator.ConnectOutWithIn(del, sink); testModel.Combinator.CommitFlow(); var simulator = new Simulator(testModel); //Important: Call after all objects have been created simulator.SimulateStep(); var flowCombinatorAfterStep = (IntFlowCombinator)simulator.Model.Roots[0]; var flowComponentsAfterStep = ((IntFlowComponentCollection)simulator.Model.Roots[1]).Components; var sourceAfterStep = (IntFlowSource)flowComponentsAfterStep[0]; var delAfterStep = (IntFlowDelegate)flowComponentsAfterStep[1]; var sinkAfterStep = (IntFlowSink)flowComponentsAfterStep[2]; sourceAfterStep.Outgoing.Forward.Should().Be((Int)7); delAfterStep.Incoming.Forward.Should().Be((Int)7); delAfterStep.Outgoing.Forward.Should().Be((Int)7); sinkAfterStep.Incoming.Forward.Should().Be((Int)7); sinkAfterStep.Incoming.Backward.Should().Be(1); delAfterStep.Outgoing.Backward.Should().Be(1); delAfterStep.Incoming.Backward.Should().Be(1); sourceAfterStep.Outgoing.Backward.Should().Be(1); }
public void DelegateFlowArrives() { var testModel = new IntFlowModel(); var source = new IntFlowSource(); var del = new IntFlowDelegate(); var sink = new IntFlowSink(); testModel.Components = new IntFlowComponentCollection(source, del, sink); source.SendForward = testModel.CreateForward; source.ReceivedBackward = testModel.PrintReceivedBackward; sink.SendBackward = testModel.CreateBackward; sink.ReceivedForward = testModel.PrintReceivedForward; testModel.Combinator.ConnectOutWithIn(source, del); testModel.Combinator.ConnectOutWithIn(del, sink); testModel.Combinator.CommitFlow(); var simulator = new Simulator(testModel); //Important: Call after all objects have been created simulator.SimulateStep(); var flowCombinatorAfterStep = (IntFlowCombinator)simulator.Model.Roots[0]; var flowComponentsAfterStep = ((IntFlowComponentCollection)simulator.Model.Roots[1]).Components; var sourceAfterStep = (IntFlowSource)flowComponentsAfterStep[0]; var delAfterStep = (IntFlowDelegate)flowComponentsAfterStep[1]; var sinkAfterStep = (IntFlowSink)flowComponentsAfterStep[2]; sourceAfterStep.Outgoing.Forward.Should().Be((Int)7); delAfterStep.Incoming.Forward.Should().Be((Int)7); delAfterStep.Outgoing.Forward.Should().Be((Int)7); sinkAfterStep.Incoming.Forward.Should().Be((Int)7); sinkAfterStep.Incoming.Backward.Should().Be(1); delAfterStep.Outgoing.Backward.Should().Be(1); delAfterStep.Incoming.Backward.Should().Be(1); sourceAfterStep.Outgoing.Backward.Should().Be(1); }