Exemplo n.º 1
0
        public async Task TestMessageDispatcher()
        {
            var logger = new MockLogger();

            var container = new Container(configuration => configuration.AddRegistry <BusRegistry>());

            var messages1 = Enumerable.Range(0, 50)
                            .Select(_ => new TestMessage())
                            .Select(msg => new MessageDispatch(msg))
                            .ToList();

            var messages2 = Enumerable.Range(0, 100)
                            .Select(_ => new TestMessage2())
                            .Select(msg => new MessageDispatch(msg))
                            .ToList();


            Assert.AreEqual(0, TestsMessageDispatchingContext.Get());
            Assert.AreEqual(0, TestsMessageDispatchingContext2.Get());

            var messageDispatcher = new MessageDispatcher(logger, container);

            messageDispatcher.Dispatch(messages1.Concat(messages2).ToList());

            await Task.Delay(1000);

            Assert.AreEqual(100, TestsMessageDispatchingContext.Get());

            Assert.AreEqual(100, TestsMessageDispatchingContext2.Get());
        }
Exemplo n.º 2
0
 public void SetUp()
 {
     TestsMessageDispatchingContext.Reset();
     TestsMessageDispatchingContext2.Reset();
 }