Пример #1
0
        public void HandleMessage_InvalidChannel_WithLead_ExpectNoLeadInserted()
        {
            //Arrange
            Lead testLead = new Lead()
            {
                FirstName = "Test",
                LastName  = "Tester",
                Company   = "ISC2",
                Email     = "*****@*****.**"
            };

            IncomingLeadHandler testHandler = new IncomingLeadHandler();

            //Act
            PubSubService.Instance.Subscribe(testHandler);

            int leadsBeforePublishCount = GetLeads().Count;

            PubSubService.Instance.Publish("nope", testLead);
            List <Lead> leadsAfterPublish = GetLeads();

            //Assert
            Assert.AreEqual(0, leadsBeforePublishCount, "Expect no leads.");
            Assert.AreEqual(0, leadsAfterPublish.Count, "Expect no leads.");
        }
Пример #2
0
        public void HandleMessage_ValidLead_ExpectInsert()
        {
            //Arrange
            Lead testLead = new Lead()
            {
                FirstName = "Test",
                LastName  = "Tester",
                Company   = "ISC2",
                Email     = "*****@*****.**"
            };

            IncomingLeadHandler testHandler = new IncomingLeadHandler();

            //Act
            PubSubService.Instance.Subscribe(testHandler);

            int leadsBeforePublishCount = GetLeads().Count;

            PubSubService.Instance.Publish(IncomingLeadHandler.INCOMING_LEAD_CHANNEL, testLead);
            List <Lead> leadsAfterPublish = GetLeads();

            //Assert
            Assert.AreEqual(0, leadsBeforePublishCount, "Expect no leads.");
            Assert.AreEqual(1, leadsAfterPublish.Count, "Expect one lead.");
            Assert.AreEqual(testLead.FirstName, leadsAfterPublish[0].FirstName, "Expect the test lead.");
        }
Пример #3
0
        public void HandleMessage_MultipleDifferentSubscribersWithOneUsubscribe_ExpectOneLeadInserted()
        {
            //Arrange
            Lead testLead = new Lead()
            {
                FirstName = "Test",
                LastName  = "Tester",
                Company   = "ISC2",
                Email     = "*****@*****.**"
            };

            IncomingLeadHandler testHandler     = new IncomingLeadHandler();
            IncomingLeadHandler testHandlerLms  = new IncomingLeadHandler("LMS");
            IncomingLeadHandler testHandlerOkta = new IncomingLeadHandler("OKTA");

            //Act
            PubSubService.Instance.Subscribe(testHandler);
            PubSubService.Instance.Subscribe(testHandlerLms);
            PubSubService.Instance.Subscribe(testHandlerOkta);
            PubSubService.Instance.Unsubscribe(testHandlerOkta);

            int leadsBeforePublishCount = GetLeads().Count;

            PubSubService.Instance.Publish(IncomingLeadHandler.INCOMING_LEAD_CHANNEL, testLead);
            List <Lead> leadsAfterPublish = GetLeads();

            //Assert
            Assert.AreEqual(0, leadsBeforePublishCount, "Expect no leads.");
            Assert.AreEqual(2, leadsAfterPublish.Count, "Expect two leads.");
        }
Пример #4
0
        public void HandleMessage_NullChannel_ExpectThrowsArgumentNullException()
        {
            //Arrange
            IncomingLeadHandler testHandler = new IncomingLeadHandler();

            //Act and Assert
            Assert.ThrowsException <System.ArgumentNullException>(() => testHandler.HandleMessage(null, null));
        }
Пример #5
0
        public void HandleMessage_InvalidLead_ExpectThrowsArgumentException()
        {
            //Arrange
            Lead testLead = new Lead()
            {
                FirstName = null,
                LastName  = "Tester",
                Company   = "ISC2",
                Email     = "*****@*****.**"
            };

            IncomingLeadHandler testHandler = new IncomingLeadHandler();

            //Act
            PubSubService.Instance.Subscribe(testHandler);

            List <Lead> leads = GetLeads();

            //Act and Assert
            Assert.ThrowsException <System.ArgumentException>(() => PubSubService.Instance.Publish(IncomingLeadHandler.INCOMING_LEAD_CHANNEL, testLead));
            Assert.AreEqual(0, leads.Count, "Expect no leads.");
        }