public void CampaignManagerDecoratorTestWithExistingCampaignManagerResultsCollection() { // Add 1 element to the CampaignManagerCollection var expectedCount = 1; _testLeadEntity.ResultCollection.CampaignManagerCollection = new IResult[] { new DefaultResult(ResultKeys.CampaignManagerKeys.CampaignsProcessedStatusKey, ResultKeys.ResultKeysStatusEnum.Processed) }; Assert.AreEqual(expectedCount, _testLeadEntity.ResultCollection.CampaignManagerCollection.Length); // Now the rest should work the same and the element above should not be overwritten var testCampaignCnt = 2; var decorator = new CampaignManagerDecorator(_loggerClient.Object); _testCampaignManagerResultList.Add(new DefaultResult(ResultKeys.CampaignManagerKeys.CampaignCountKey, testCampaignCnt)); var expectedResultListCount = _testLeadEntity.ResultCollection.CampaignManagerCollection.Length + _testCampaignManagerResultList.Count + 2; // 2 more elements added in Decorator decorator.DecorateLead(_testLeadEntity, _testCampaignManagerResultList); // Now check that the testLeadEntity ResultCollection was decorated with expected values. Assert.IsNotNull(_testLeadEntity.ResultCollection.CampaignManagerCollection); Assert.AreEqual(expectedResultListCount, _testLeadEntity.ResultCollection.CampaignManagerCollection.Length); var actualCampaignCnt = _testLeadEntity.ResultCollection.CampaignManagerCollection .SingleOrDefault(item => item.Id == ResultKeys.CampaignManagerKeys.CampaignCountKey)?.Value; Assert.AreEqual(testCampaignCnt, actualCampaignCnt); // Check that the initialized value are still in the _tetLeadEntity.ResultCollection.CampaignManagerCollection var expectedValue = _testLeadEntity.ResultCollection.CampaignManagerCollection.SingleOrDefault(item => item.Id == ResultKeys.CampaignManagerKeys.SubscriberStatusKey)?.Value; Assert.AreEqual(expectedValue.ToString(), ResultKeys.ResultKeysStatusEnum.Processed.ToString()); }
public void CampaignManagerDecoratorConstructorTestWithNullLogger() { try { var decorator = new CampaignManagerDecorator(null); Assert.Fail("An Argument Null Exception is expected when the Logger Client is null"); } catch (Exception exception) { Assert.AreEqual(typeof(ArgumentNullException), exception.GetType()); Assert.AreEqual("Value cannot be null. Parameter name: loggerClient", exception.Message.Replace(Environment.NewLine, " ")); } }
public void CampaignManagerDecoratorTestWithNullLeadEntity() { try { var decorator = new CampaignManagerDecorator(_loggerClient.Object); decorator.DecorateLead(null, _testCampaignManagerResultList); Assert.Fail("An Argument Null Exception is expected when the leadEntity is null"); } catch (Exception exception) { Assert.AreEqual(typeof(ArgumentNullException), exception.GetType()); Assert.AreEqual("Value cannot be null. Parameter name: leadEntity", exception.Message.Replace(Environment.NewLine, " ")); } }
public void CampaignManagerDecoratorTestWithDataInResultList() { var testCampaignCnt = 2; var decorator = new CampaignManagerDecorator(_loggerClient.Object); _testCampaignManagerResultList.Add(new DefaultResult(ResultKeys.CampaignManagerKeys.CampaignCountKey, testCampaignCnt)); _testCampaignManagerResultList.Add(new DefaultResult(ResultKeys.CampaignManagerKeys.CampaignsProcessedStatusKey, ResultKeys.ResultKeysStatusEnum.Processed)); var expectedResultListCount = _testCampaignManagerResultList.Count + 2; // 2 more elements added in Decorator decorator.DecorateLead(_testLeadEntity, _testCampaignManagerResultList); // Now check that the testLeadEntity ResultCollection was decorated with expected values. Assert.IsNotNull(_testLeadEntity.ResultCollection.CampaignManagerCollection); Assert.AreEqual(expectedResultListCount, _testLeadEntity.ResultCollection.CampaignManagerCollection.Length); var actualCampaignCnt = _testLeadEntity.ResultCollection.CampaignManagerCollection.SingleOrDefault(item => item.Id == ResultKeys.CampaignManagerKeys.CampaignCountKey)?.Value; Assert.AreEqual(testCampaignCnt, actualCampaignCnt); }
public void CampaignManagerDecoratorConstructorTest() { var decorator = new CampaignManagerDecorator(_loggerClient.Object); }
public void CampaignManagerDecoratorTestWithNullResultList() { var decorator = new CampaignManagerDecorator(_loggerClient.Object); decorator.DecorateLead(_testLeadEntity, null); }