Beispiel #1
0
        public void XPathRepository_GetXPathNavigator_ListAllCampaignDetailRecords_ReturnAllRecords()
        {
            // Arrange
            var dataModel = new PhoneManagerModel()
            {
                DefaultCampaignQueryStringKey = "fsource", DefaultPersistDurationInDays = 0
            };

            dataModel.PhoneManagerCampaignDetail = new List <PhoneManagerCampaignDetail>()
            {
                new PhoneManagerCampaignDetail()
                {
                    Id = "1201", TelephoneNumber = "0800 123 4567", CampaignCode = "testcode"
                },
                new PhoneManagerCampaignDetail()
                {
                    Id = "1202", TelephoneNumber = "0800 000 4567", CampaignCode = "testcode2"
                }
            };

            var testPhoneManagerData = dataModel.ToXmlString();

            var method = MockProviders.Repository(testPhoneManagerData);

            // Act
            var act = method.ListAllCampaignDetailRecords();

            // Assert
            Assert.IsTrue(act.Count == 2);
        }
Beispiel #2
0
        public void XPathRepository_GetXPathNavigator_CheckDefaultSettings_WithDefaultValueForMissingPropertyDefaultPersistDurationInDays_ReturnValid()
        {
            // Arrange
            var dataModel = new PhoneManagerModel()
            {
                DefaultCampaignQueryStringKey = "fsource", DefaultPersistDurationInDays = 0
            };

            dataModel.PhoneManagerCampaignDetail = new List <PhoneManagerCampaignDetail>()
            {
                new PhoneManagerCampaignDetail()
                {
                    Id = "1201", TelephoneNumber = "0800 123 4567", CampaignCode = "testcode"
                }
            };

            var testPhoneManagerData = dataModel.ToXmlString();

            var method = MockProviders.Repository(testPhoneManagerData);

            // Act
            var act = method.GetDefaultSettings();

            // Assert
            Assert.IsTrue(act.DefaultCampaignQueryStringKey == dataModel.DefaultCampaignQueryStringKey);
            Assert.IsTrue(act.DefaultPersistDurationInDays == 30);
        }
Beispiel #3
0
        public void XPathRepository_GetXPathNavigator_GetCampaignDetailById_WithMatchingRecord_ReturnValid()
        {
            // Arrange
            var dataModel = new PhoneManagerModel()
            {
                DefaultCampaignQueryStringKey = "fsource", DefaultPersistDurationInDays = 0
            };

            dataModel.PhoneManagerCampaignDetail = new List <PhoneManagerCampaignDetail>()
            {
                new PhoneManagerCampaignDetail()
                {
                    Id = "1201", TelephoneNumber = "0800 123 4567", CampaignCode = "testcode"
                },
                new PhoneManagerCampaignDetail()
                {
                    Id = "1202", TelephoneNumber = "0800 000 4567", CampaignCode = "testcode2"
                }
            };

            var testPhoneManagerData = dataModel.ToXmlString();

            var method = MockProviders.Repository(testPhoneManagerData);

            // Act
            var act = method.GetCampaignDetailById("1202");

            // Assert
            Assert.AreEqual("1202", act.Id);
        }
        public void CriteriaProcessor_GetMatchingRecordsFromPhoneManagerTest_WithMatchingData_EntryPageAndCampaignCodeAndReferrer_ReturnsValidResult()
        {
            // Arrange
            // generate test data
            var dataModel = new PhoneManagerModel()
            {
                DefaultCampaignQueryStringKey = "fsource", DefaultPersistDurationInDays = 32
            };

            dataModel.PhoneManagerCampaignDetail = new List <PhoneManagerCampaignDetail>()
            {
                new PhoneManagerCampaignDetail()
                {
                    Id = "1201", TelephoneNumber = "0800 123 4567", CampaignCode = "thisisrubbish", Referrer = "sub.domain.co.uk"
                },
                new PhoneManagerCampaignDetail()
                {
                    Id = "1302", TelephoneNumber = "0800 000 0000", CampaignCode = "dummy", Referrer = "domain.co.uk"
                },
                new PhoneManagerCampaignDetail()
                {
                    Id = "1203", TelephoneNumber = "9999 999 9999", CampaignCode = "dummy2", EntryPage = "AboutUs"
                },
                new PhoneManagerCampaignDetail()
                {
                    Id = "1204", TelephoneNumber = "8888 888 8888", CampaignCode = "testcode", EntryPage = "AboutUs"
                },
                new PhoneManagerCampaignDetail()
                {
                    Id = "1205", TelephoneNumber = "7777 777 7777", CampaignCode = "testcode", EntryPage = "AboutUs", Referrer = "domain.co.uk"
                }
            };
            var testPhoneManagerData = dataModel.ToXmlString();

            IRepository _repository = MockProviders.Repository(testPhoneManagerData);

            var criteriaParameters = new CriteriaParameterHolder()
            {
                CleansedQueryStrings = new NameValueCollection()
                {
                    { "fsource", "testcode" }
                },
                RequestInfo_NotIncludingQueryStrings = new PhoneManagerCampaignDetail()
                {
                    Referrer = "www.domain.co.uk", EntryPage = "AboutUs"
                }
            };

            var criteria = new CriteriaProcessor(criteriaParameters, _repository);

            // Act
            var results = criteria.GetMatchingRecordFromPhoneManager();

            // Assert
            Assert.IsNotNull(results);
            Assert.AreEqual(results.Id, "1205");
        }
        public void ReferrerCriteria_GetMatchingRecordsFromPhoneManagerTest_WithTopTierDomainAndSubDomainWithMatchingReferrerAndCloseMatch_ReturnsCorrectResult()
        {
            // Arrange
            // generate test data
            var dataModel = new PhoneManagerModel()
            {
                DefaultCampaignQueryStringKey = "fsource", DefaultPersistDurationInDays = 32
            };

            dataModel.PhoneManagerCampaignDetail = new List <PhoneManagerCampaignDetail>()
            {
                new PhoneManagerCampaignDetail()
                {
                    Id = "1201", TelephoneNumber = "0800 123 4567", CampaignCode = "testcode", Referrer = "www.google.co.uk"
                },
                new PhoneManagerCampaignDetail()
                {
                    Id = "1202", TelephoneNumber = "9909 999 9999", CampaignCode = "testcode2", Referrer = "google.com"
                },
                new PhoneManagerCampaignDetail()
                {
                    Id = "1203", TelephoneNumber = "8888 888 8888", CampaignCode = "testcode3", Referrer = "google.co.uk"
                }
            };
            var testPhoneManagerData = dataModel.ToXmlString();

            IRepository _repository = MockProviders.Repository(testPhoneManagerData);

            var criteriaParameters = new CriteriaParameterHolder()
            {
                CleansedQueryStrings = null,
                RequestInfo_NotIncludingQueryStrings = new PhoneManagerCampaignDetail()
                {
                    Referrer = "www.search.google.co.uk"
                }
            };

            var criteria = new ReferrerCriteria();

            // Act
            var results = criteria.GetMatchingRecordsFromPhoneManager(criteriaParameters, _repository);

            // Assert
            Assert.IsNotNull(results);
            Assert.AreEqual(results.Count(), 1);
            Assert.AreEqual(results.First().Id, "1203");
        }
Beispiel #6
0
        public void QueryStringCriteria_GetMatchingRecordsFromPhoneManagerTest_WithMatchingQS_ReturnsCorrectResults()
        {
            // Arrange
            // generate test data
            var dataModel = new PhoneManagerModel()
            {
                DefaultCampaignQueryStringKey = "fsource", DefaultPersistDurationInDays = 32
            };

            dataModel.PhoneManagerCampaignDetail = new List <PhoneManagerCampaignDetail>()
            {
                new PhoneManagerCampaignDetail()
                {
                    Id = "1201", TelephoneNumber = "0800 123 4567", CampaignCode = "testcode"
                }
            };
            var testPhoneManagerData = dataModel.ToXmlString();

            IRepository _repository = MockProviders.Repository(testPhoneManagerData);

            var criteriaParameters = new CriteriaParameterHolder()
            {
                CleansedQueryStrings = new NameValueCollection()
                {
                    { "dummykey", "nothing" }, { "fsource", "testcode" }
                },
                RequestInfo_NotIncludingQueryStrings = new PhoneManagerCampaignDetail()
                {
                    EntryPage = dataModel.PhoneManagerCampaignDetail.First().EntryPage
                }
            };

            var criteria = new QueryStringCriteria();

            // Act
            var results = criteria.GetMatchingRecordsFromPhoneManager(criteriaParameters, _repository);

            // Assert
            Assert.IsNotNull(results);
            Assert.AreEqual(results.Count(), 1);
            Assert.AreEqual(results.First().CampaignCode, dataModel.PhoneManagerCampaignDetail.First().CampaignCode);
        }
        public void CriteriaProcessor_GetMatchingRecordsFromPhoneManagerTest_WithNoMatchingData_ButWithDefault_ReturnsDefaultRecord()
        {
            // Arrange
            // generate test data
            var dataModel = new PhoneManagerModel()
            {
                DefaultCampaignQueryStringKey = "fsource", DefaultPersistDurationInDays = 32
            };

            dataModel.PhoneManagerCampaignDetail = new List <PhoneManagerCampaignDetail>()
            {
                new PhoneManagerCampaignDetail()
                {
                    Id = "1201", TelephoneNumber = "0800 123 4567", CampaignCode = "testcode"
                },
                new PhoneManagerCampaignDetail()
                {
                    Id = "1202", TelephoneNumber = "0800 000 0000", IsDefault = true
                }
            };
            var testPhoneManagerData = dataModel.ToXmlString();

            IRepository _repository = MockProviders.Repository(testPhoneManagerData);

            var criteriaParameters = new CriteriaParameterHolder()
            {
                CleansedQueryStrings = null,
                RequestInfo_NotIncludingQueryStrings = new PhoneManagerCampaignDetail()
                {
                }
            };

            var criteria = new CriteriaProcessor(criteriaParameters, _repository);

            // Act
            var results = criteria.GetMatchingRecordFromPhoneManager();

            // Assert
            Assert.IsNotNull(results);
            Assert.AreEqual("1202", results.Id);
        }
        public void ReferrerCriteria_GetMatchingRecordsFromPhoneManagerTest_WithNoMatchingReferrer_ReturnsEmptyResults()
        {
            // Arrange
            // generate test data
            var dataModel = new PhoneManagerModel()
            {
                DefaultCampaignQueryStringKey = "fsource", DefaultPersistDurationInDays = 32
            };

            dataModel.PhoneManagerCampaignDetail = new List <PhoneManagerCampaignDetail>()
            {
                new PhoneManagerCampaignDetail()
                {
                    Id = "1201", TelephoneNumber = "0800 123 4567", CampaignCode = "testcode", Referrer = "google.co.uk"
                }
            };
            var testPhoneManagerData = dataModel.ToXmlString();

            IRepository _repository = MockProviders.Repository(testPhoneManagerData);

            var criteriaParameters = new CriteriaParameterHolder()
            {
                CleansedQueryStrings = null,
                RequestInfo_NotIncludingQueryStrings = new PhoneManagerCampaignDetail()
                {
                    Referrer = "bing.com"
                }
            };

            var criteria = new ReferrerCriteria();

            // Act
            var results = criteria.GetMatchingRecordsFromPhoneManager(criteriaParameters, _repository);

            // Assert
            Assert.IsNotNull(results);
            Assert.AreEqual(results.Count(), 0);
        }