public void TestMethod2()
        {
            var exceptionHandler = Mock.Create <IExceptionHandler>();

            Mock.Arrange(() => exceptionHandler.Handle(null)).IgnoreArguments().Returns <Exception>(o =>
            {
                Console.WriteLine(o);
                return(true);
            });

            var itemStore    = new ItemStore();
            var uniqueQueue  = new ItemsQueueContainer <ItemWithDate>();
            var infinityPipe = new InfinityPipe <ItemWithDate>(uniqueQueue);

            var dataflow = DataflowBuilder
                           .StartFrom(infinityPipe)
                           .ConvertItemsTo(o => new ScheduledTransmitterItem <int>(o.DateTime, o.Num, stopSchedule: o.Count == 4))
                           .TransmitWith(o => o.ScheduledTransmitter(new DateTimeProvider(), exceptionHandler))
                           .Transform(itemStore.GetItem)
                           .BroadcastTo(t1 => t1.SendToTarget(new LoggingTarget <ItemWithDate>()),
                                        t2 => t2.Transform(o =>
            {
                o.Count++;
                o.DateTime = DateTime.Now.AddSeconds(o.Num + 1);
                return(o);
            })
                                        .RouteTo(condition => condition.Case(o => o.Count == 4)
                                                 .BroadcastTo(t21 => t21.SendToTarget(new DeleteTarget(itemStore)),
                                                              t22 => t22.SendToTarget(infinityPipe)),

                                                 condition => condition.Default()
                                                 .BroadcastTo(t21 => t21.SendToTarget(new UpdateTarget(itemStore)),
                                                              t22 => t22.SendToTarget(infinityPipe))))
                           .Build();

            dataflow.Start();

            var items = itemStore.Load();

            foreach (var item in items)
            {
                infinityPipe.SendAsync(item).Wait();
            }

            Task.Delay(10000).Wait();
        }
 public DeleteTarget(ItemStore itemStore)
 {
     _itemStore = itemStore;
 }
 public UpdateTarget(ItemStore itemStore)
 {
     _itemStore = itemStore;
 }