Ejemplo n.º 1
0
        public void Should_capture_the_interval_channel()
        {
            var channel = new ConsumerChannel<ICollection<int>>(new SynchronousFiber(), x => { });
            var scheduler = new TimerFiberScheduler(new SynchronousFiber());
            var interval = new IntervalChannel<int>(new SynchronousFiber(), scheduler, 5.Minutes(), channel);

            new ChannelVisitor().Visit(interval);
        }
Ejemplo n.º 2
0
        public void Should_capture_the_interval_channel()
        {
            var channel   = new ConsumerChannel <ICollection <int> >(new SynchronousFiber(), x => { });
            var scheduler = new TimerScheduler(new SynchronousFiber());
            var interval  = new IntervalChannel <int>(new SynchronousFiber(), scheduler, 5.Minutes(), channel);

            new ChannelVisitor().Visit(interval);
        }
Ejemplo n.º 3
0
        protected override Channel <T> Visitor <T>(IntervalChannel <T> channel)
        {
            _current = GetVertex(channel.GetHashCode(), () => "Interval", typeof(IntervalChannel <T>), typeof(ICollection <T>));

            if (_stack.Count > 0)
            {
                _edges.Add(new Edge(_stack.Peek(), _current, _current.TargetType.Name));
            }

            return(WithVertex(() => base.Visitor(channel)));
        }
Ejemplo n.º 4
0
        public void Should_deliver_the_messages_at_once()
        {
            var queue     = new SynchronousFiber();
            var scheduler = new TimerScheduler(new SynchronousFiber());

            var called   = new Future <ICollection <MyMessage> >();
            var consumer = new ConsumerChannel <ICollection <MyMessage> >(queue, called.Complete);

            var channel = new IntervalChannel <MyMessage>(queue, scheduler, 2.Seconds(), consumer);

            for (int i = 0; i < 5; i++)
            {
                channel.Send(new MyMessage());
            }

            called.WaitUntilCompleted(4.Seconds()).ShouldBeTrue();

            channel.Dispose();

            called.Value.ShouldNotBeNull();
            called.Value.Count.ShouldEqual(5);
        }
Ejemplo n.º 5
0
		public void Should_deliver_the_messages_at_once()
		{
			var queue = new SynchronousFiber();
			var scheduler = new TimerScheduler(new SynchronousFiber());

			var called = new Future<ICollection<MyMessage>>();
			var consumer = new ConsumerChannel<ICollection<MyMessage>>(queue, called.Complete);

			var channel = new IntervalChannel<MyMessage>(queue, scheduler, 2.Seconds(), consumer);

			for (int i = 0; i < 5; i++)
			{
				channel.Send(new MyMessage());
			}

			called.WaitUntilCompleted(4.Seconds()).ShouldBeTrue();

			channel.Dispose();

			called.Value.ShouldNotBeNull();
			called.Value.Count.ShouldEqual(5);
		}
Ejemplo n.º 6
0
        protected virtual Channel <T> Visitor <T>(IntervalChannel <T> channel)
        {
            Visit(channel.Output);

            return(channel);
        }
Ejemplo n.º 7
0
        protected override Channel <T> Visitor <T>(IntervalChannel <T> channel)
        {
            Trace.WriteLine("IntervalChannel<{0}>, Interval = {1}".FormatWith(typeof(T).Name, channel.Interval));

            return(base.Visitor(channel));
        }