Ejemplo n.º 1
0
        public void LeadPublisherPublishLeadTest()
        {
            var          testChannel     = new InProcNotificationChannel <ILeadEntity>(new Mock <ILogger>().Object);
            var          testPublisher   = new Publisher <ILeadEntity>(new INotificationChannel <ILeadEntity>[] { testChannel }, true);
            var          testSubscriber  = new Subscriber <ILeadEntity>(testChannel, true);
            const string expectedMessage =
                "{\"Context\":null,\"Properties\":[{\"Id\":\"testKey\",\"Value\":\"testValue\"}],\"Segments\":null,\"Results\":null}";


            var leadPublisher = new LeadPublisher(testPublisher, new Mock <ILoggerClient>().Object);

            var testProperty = new TestProperty
            {
                Id    = "testKey",
                Value = "testValue"
            };

            var testLead = new TestLeadEntity
            {
                Properties = new IProperty[] { testProperty }
            };
            var actualLead = new TestLeadEntity();

            testSubscriber.AddOnReceiveActionToChannel(testlead => actualLead = testLead);

            leadPublisher.PublishLead(testLead);

            Thread.Sleep(5); //Speed bump to let the threads process.

            Assert.AreEqual(testLead, actualLead);
        }