Esempio n. 1
0
        public void CampaignManagerSubscriberAddOnReceiveActionToChannel()
        {
            var testNotificationChannel   = new InProcNotificationChannel <ILeadEntity>(new Mock <ILogger>().Object);
            var testNotificationPublisher =
                new Publisher <ILeadEntity>(new INotificationChannel <ILeadEntity>[] { testNotificationChannel }, true);
            var testNotificationSubscriber = new Subscriber <ILeadEntity>(testNotificationChannel, true);

            // Set up the action to be invoked when a leadEntity is received
            bool actionWasInvoked = false;
            Action <ILeadEntity> leadEntityReceiveAction = campaignManagerDriver => actionWasInvoked = true;

            // Setup the Subscriber to execute the action when invoked
            var campaignManagerSubscriber =
                new CampaignManagerSubscriber(testNotificationSubscriber, _loggerClient.Object);

            campaignManagerSubscriber.SetupAddOnReceiveActionToChannel(leadEntityReceiveAction);

            // Let the Notification Publisher broadcast a leadEntity
            testNotificationPublisher.BroadcastMessage(_testLleadEntity);

            // Sleep a little while for the Notification Channel to pick up the LeadEntity
            Thread.Sleep(5);

            // The subscriber should now have executed the action
            Assert.AreEqual(true, actionWasInvoked);
        }