Exemplo n.º 1
0
        public void TestCampaignIfControllerReturnsSuccess()
        {
            // The process lead function adds results to the Campaign Results list
            var expecteResultsIfControlReturnsFalse = 9;
            // A campaign
            var campaign = new Implementation.Campaign(_campaignId, _campaignDescription, _campaignPriority,
                                                       _campaignServiceProvider.GetService <ICampaignConfig>(),
                                                       _campaignServiceProvider.GetService <ILoggerClient>());

            // Setting up the validator to return true
            _campaignConfig.Setup(v => v.CampaignValidator.ValidLead(It.IsAny <ILeadEntity>())).Returns(true);

            // Setting up the Campaign Controller - This will process through the Rules and Filters for the Campaign
            // Mock it to return a success
            _campaignConfig.Setup(v => v.CampaignController.ConstraintMet(It.IsAny <ILeadEntity>())).Returns(true);

            // Let the Campaign Process the Lead
            _campaignResultList = campaign.ProcessLead(_testLeadEntity);

            // Evaluate if the number of results in results list is as expected
            Assert.AreEqual(expecteResultsIfControlReturnsFalse, _campaignResultList.Count);

            // looks in the results collection to see if the validator said the lead processed
            var expectedValue = _campaignResultList.SingleOrDefault(item =>
                                                                    item.Id == ResultKeys.CampaignKeys.ControlStatusKey)?.Value;

            Assert.AreEqual(expectedValue.ToString(), ResultKeys.ResultKeysStatusEnum.Processed.ToString());
        }
Exemplo n.º 2
0
        public void TestLeadValidationForACampaignReturnFalse()
        {
            // The process lead function adds results to the Campaign Results list
            var expecteResultsIfValidatorReturnsFalse = 6;

            // A campaign
            var campaign = new Implementation.Campaign(_campaignId, _campaignDescription, _campaignPriority,
                                                       _campaignServiceProvider.GetService <ICampaignConfig>(),
                                                       _campaignServiceProvider.GetService <ILoggerClient>());

            // Setting up the campaign validator to return false
            _campaignConfig.Setup(v => v.CampaignValidator.ValidLead(It.IsAny <ILeadEntity>())).Returns(false);

            // Let the Campaign Process the Lead
            _campaignResultList = campaign.ProcessLead(_testLeadEntity);

            //// Evaluate if the number of results in results list is as expected
            Assert.AreEqual(expecteResultsIfValidatorReturnsFalse, _campaignResultList.Count);

            // looks in the results collection to see if the validator said the lead failed
            var actualValue = _campaignResultList.SingleOrDefault(item =>
                                                                  item.Id == ResultKeys.ValidatorStatusKey)?.Value;

            Assert.AreEqual(actualValue.ToString(), ResultKeys.ResultKeysStatusEnum.Failed.ToString());
        }
Exemplo n.º 3
0
        public void ProcessLeadNullLeadEntityTest()
        {
            var campaign = new Implementation.Campaign(_campaignId, _campaignDescription, _campaignPriority,
                                                       _campaignServiceProvider.GetService <ICampaignConfig>(),
                                                       _campaignServiceProvider.GetService <ILoggerClient>());

            campaign.ProcessLead(null);
        }