public override Property Check(IChannelPipeline obj0, PipelineMutationModel obj1) { var removed = obj0.RemoveLast() as NamedChannelHandler; var embeddedChannel = obj0.Channel() as EmbeddedChannel; Contract.Assert(embeddedChannel != null); embeddedChannel.RunPendingTasks(); // force the pipeline to run all scheduled tasks var pFirst = obj0.Reverse().Skip(1).First(); //bypass the head node var mFirst = obj1.Tail.Previous.Handler; var pLength = obj0.Count(); var prop = (pFirst == mFirst) .Label($"Expected tail of pipeline to be {mFirst}, was {pFirst}") .And(() => pLength == obj1.Length) .Label($"Expected length of pipeline to be {obj1.Length}, was {pLength}"); /* * This one is weird, because we don't have a reference to the removed handler on the model anymore. * So we compare the result to what was expected from the handler instead. */ if (removed != null && removed.SupportsEvent(SupportedEvent.HandlerRemoved)) { prop = prop.And(() => removed.LastFiredEvent == SupportedEvent.HandlerRemoved) .Label( $"Expected last fired property of handler to be {SupportedEvent.HandlerRemoved}, but was {removed.LastFiredEvent}"); } return(prop); }
public override bool Pre(PipelineMutationModel _arg1) { var outcome = _arg1.PredictedOutcome(Event); return(_arg1.Length > 2 && base.Pre(_arg1) && outcome.Any()); // need to have at least 1 handler who can take the event }
public override PipelineMutationModel Run(PipelineMutationModel obj0) { var newNode = NewHandler(); var model = AddToTail(obj0, newNode); return(model); }
public override Property Check(IChannelPipeline obj0, PipelineMutationModel obj1) { var model = obj1.PredictedOutcome(Event); var actual = Execute(obj0); return (model.SequenceEqual(actual) .Label( $"Expected model ({string.Join(",", model)}) to equal actual ({string.Join(",", actual)})")); }
public void PipelineModel_should_no_longer_detect_named_nodes_removed_from_tail() { var namedChannel = new NamedChannelHandler("TEST"); var node = new PipelineModelNode { Handler = namedChannel, Name = namedChannel.Name }; var pipelineModel = PipelineMutationModel.Fresh(); pipelineModel = AddToTail(pipelineModel, node); Assert.True(pipelineModel.Contains(node.Name)); pipelineModel = RemoveTail(pipelineModel); Assert.False(pipelineModel.Contains(namedChannel.Name)); }
public override Property Check(IChannelPipeline obj0, PipelineMutationModel obj1) { var pipeline = obj0 as DefaultChannelPipeline; var head = obj1.Head; var next = head.Next; while (next != null && next != obj1.Tail) { var inPipe = pipeline.Get(next.Name); if (inPipe != next.Handler) { return(false.Label($"Expected to find handler {inPipe} in pipeline, but did not")); } next = next.Next; } return(true.ToProperty()); }
public override Property Check(IChannelPipeline obj0, PipelineMutationModel obj1) { var pipeline = obj0.AddLast(Name, Handler); var embeddedChannel = obj0.Channel() as EmbeddedChannel; Contract.Assert(embeddedChannel != null); embeddedChannel.RunPendingTasks(); // force the pipeline to run all scheduled tasks var pFirst = pipeline.Reverse().Skip(1).First(); //bypass the head node var mFirst = obj1.Tail.Previous.Handler; var pLength = pipeline.Count(); var prop = (pFirst == mFirst) .Label($"Expected tail of pipeline to be {mFirst}, was {pFirst}") .And(() => pLength == obj1.Length) .Label($"Expected length of pipeline to be {obj1.Length}, was {pLength}"); return(CheckEventInQueue(mFirst, SupportedEvent.HandlerAdded, prop, LastEventHistory(obj0))); }
public void PipelineModel_should_detect_named_nodes_added_to_tail() { var namedChannel = new NamedChannelHandler("TEST"); var namedChannel2 = new NamedChannelHandler("TEST2"); var node = new PipelineModelNode { Handler = namedChannel, Name = namedChannel.Name }; var pipelineModel = PipelineMutationModel.Fresh(); pipelineModel = AddToTail(pipelineModel, node); Assert.True(pipelineModel.Contains(node.Name)); var node2 = new PipelineModelNode { Handler = namedChannel2, Name = namedChannel2.Name }; pipelineModel = AddToTail(pipelineModel, node2); Assert.True(pipelineModel.Contains(node.Name)); Assert.True(pipelineModel.Contains(node2.Name)); }
public override PipelineMutationModel Run(PipelineMutationModel obj0) { return(obj0); }
public override PipelineMutationModel Run(PipelineMutationModel obj0) { return(RemoveTail(obj0)); }
public override bool Pre(PipelineMutationModel _arg1) { return(_arg1.Length > 3 && base.Pre(_arg1)); // need to have at least 4 }
public override bool Pre(PipelineMutationModel _arg1) { // Can't allow two handlers with the same name to be added return(!_arg1.Contains(Name) && base.Pre(_arg1)); }
public override PipelineMutationModel Run(PipelineMutationModel obj0) { // state of the model is not affected return(obj0); }