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."); }
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."); }
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."); }
public void HandleMessage_NullChannel_ExpectThrowsArgumentNullException() { //Arrange IncomingLeadHandler testHandler = new IncomingLeadHandler(); //Act and Assert Assert.ThrowsException <System.ArgumentNullException>(() => testHandler.HandleMessage(null, null)); }
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."); }