Exemplo n.º 1
0
        public void DynamicSubscription_ShouldNotTrigger_AfterRemove()
        {
            var eventBus = new InProcessServiceBus();
            var result   = "error";

            Func <dynamic, Task> delateFunc = eventData =>
            {
                return(Task.Run(() =>
                {
                    result = eventData.Msg;
                }));
            };

            eventBus.AddDynamicSubscription(typeof(TestEventData).Name, delateFunc);

            var testEventData = new TestEventData()
            {
                Msg = "success"
            };

            eventBus.PublishSync(testEventData);

            Assert.AreEqual(testEventData.Msg, result);

            result = "error";
            eventBus.RemoveDynamicSubscription(typeof(TestEventData).Name, delateFunc);
            eventBus.PublishSync(testEventData);
            Assert.AreNotEqual(testEventData.Msg, result);
        }