示例#1
0
            public override Property Check(IChannelPipeline obj0, PipelineMutationModel obj1)
            {
                var removed         = obj0.RemoveFirst() 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.Skip(1).First(); //bypass the head node
                var mFirst  = obj1.Head.Next.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);
            }