Ejemplo n.º 1
0
        public void Failing_poller_should_not_interfere_with_other_pollers()
        {
            var builder = new ContainerBuilder();
            builder.Register(c => new TestPoller("p1", 0, 10)).Named<IPoller>("svc1").SingleInstance();
            builder.Register(c => new FailingPoller("p2", 2, 10)).Named<IPoller>("svc2").SingleInstance();

            var sut = new MultiPoller(builder.Build(), new[] { "svc1", "svc2" }, TimeSpan.Zero);

            sut.Start();
            WaitFor(48);
            sut.Stop();

            Log.ToArray().Should().Have.SameSequenceAs(new[] {
                "p1 ctor",
                "p2 ctor",
                "p1 poll",
                "p2 error",
                "p1 poll",
                "p2 error",
                "p1 poll",
                "p2 error",
                "p1 poll",
                "p2 error",
                "p1 poll",
                "p2 error",
            });
        }
Ejemplo n.º 2
0
        public void Should_delegate_to_ioc_poller_lifetime()
        {
            var builder = new ContainerBuilder();
            builder.Register(c => new TestPoller("p1", 0, 10)).Named<IPoller>("svc1").InstancePerLifetimeScope();

            var sut = new MultiPoller(builder.Build(), new []{"svc1"}, TimeSpan.Zero);

            sut.Start();
            WaitFor(45);
            sut.Stop();

            Log.ToArray().Should().Have.SameSequenceAs(new[] {
                "p1 ctor",
                "p1 poll",
                "p1 ctor",
                "p1 poll",
                "p1 ctor",
                "p1 poll",
                "p1 ctor",
                "p1 poll",
                "p1 ctor",
                "p1 poll"
            });
        }
Ejemplo n.º 3
0
        public void Should_execute_pollers_in_parallel()
        {
            var builder = new ContainerBuilder();
            builder.Register(c => new TestPoller("p1", 0, 10)).Named<IPoller>("svc1").SingleInstance();
            builder.Register(c => new TestPoller("p2", 2, 10)).Named<IPoller>("svc2").SingleInstance();

            var container = builder.Build();

            var sut = new MultiPoller(container, new[] { "svc1", "svc2" }, TimeSpan.Zero);

            sut.Start();
            WaitFor(48);
            sut.Stop();

            Log.ToArray().Should().Have.SameSequenceAs(new[] {
                "p1 ctor",
                "p2 ctor",
                "p1 poll",
                "p2 poll",
                "p1 poll",
                "p2 poll",
                "p1 poll",
                "p2 poll",
                "p1 poll",
                "p2 poll",
                "p1 poll",
                "p2 poll",
            });
        }