Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 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 PhoneManagerApp_ProcessAllPotentialCandidatePhoneNumbers_WithCookie_WithFoundPhoneNumberNoPersist_ReturnsCookie()
        {
            // 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();

            var _dataProvider = MockProviders.Repository(testPhoneManagerData);

            var foundRecord = new PhoneManagerCampaignDetail()
            {
                Id = "1201", TelephoneNumber = "FOUND PHONENUMBER"
            };

            var _cookie = new CookieHolder()
            {
                Model =
                    new OutputModel()
                {
                    Id = "1202",
                    TelephoneNumber = "9999 999 9999"
                }
            };

            // generate the required result
            var correctResult = new FinalResultModel()
            {
                OutputCookieHolder = new CookieHolder(),
                OutputModelResult  = new OutputModel()
                {
                    Id = "1202",
                    TelephoneNumber = "9999 999 9999"
                },
                OutputResultSource = OutputSource.ExisitingCookie
            };

            PhoneManager target = new PhoneManager(null, _dataProvider, null, null, null, null);

            //Act
            FinalResultModel retVal = target.ProcessAllPotentialCandidatePhoneNumbers(_cookie, foundRecord);

            //Assert
            Assert.AreEqual(retVal.OutputResultSource, correctResult.OutputResultSource);
            Assert.AreEqual(retVal.OutputModelResult.Id, correctResult.OutputModelResult.Id);
        }
        public void PhoneManagerApp_ProcessRequest_WithNoInputsWithDefaultTelephoneNumber_ReturnsDefaultTelephoneNumber()
        {
            // 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 1111", CampaignCode = "testcode2"
                },
                new PhoneManagerCampaignDetail()
                {
                    Id = "1203", TelephoneNumber = "0800 999 9999", IsDefault = true
                }
            };
            var testPhoneManagerData = dataModel.ToXmlString();

            var AppParamHolder = new MockProviders.PhoneManagerAppParamHolder
                                 (
                new CookieHolder(),        // cookie
                testPhoneManagerData,      // repository data
                new NameValueCollection(), // querystring
                "",                        // referrer
                new OutputModel(),         // session
                ""                         // umbraco current page id
                                 );

            // generate the required result

            PhoneManager app = new PhoneManager(AppParamHolder.CookieProvider, AppParamHolder.RepositoryProvider, AppParamHolder.QueryStringProvider, AppParamHolder.ReferrerProvider, AppParamHolder.SessionProvider, AppParamHolder.UmbracoProvider);

            //Act
            OutputModel actualResult = app.ProcessRequest();

            //Assert
            Assert.IsNotNull(actualResult.Id);
            Assert.AreEqual("1203", actualResult.Id);
        }
        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");
        }
        public void PhoneManagerApp_ProcessAllPotentialCandidatePhoneNumbers_WithNoCookie_WithNoFoundPhoneNumber_WithNoDefaultPhonenumber_ReturnsLastResortPhoneNumber()
        {
            // 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();

            var _dataProvider = MockProviders.Repository(testPhoneManagerData);

            // generate the required result
            var correctResult = new FinalResultModel()
            {
                OutputCookieHolder = null,
                OutputModelResult  = new OutputModel()
                {
                    TelephoneNumber = AppConstants.LastResortPhoneNumberPlaceholder
                },
                OutputResultSource = OutputSource.LastResortPlaceholder
            };

            PhoneManager target = new PhoneManager(null, _dataProvider, null, null, null, null);
            //PrivateObject obj = new PrivateObject(target); // MS Test

            //Act
            FinalResultModel retVal = target.ProcessAllPotentialCandidatePhoneNumbers(new CookieHolder(), new PhoneManagerCampaignDetail());

            //FinalResultModel retVal = (FinalResultModel)obj.Invoke("ProcessAllPotentialCandidatePhoneNumbers", new object[] { new CookieHolder(), new PhoneManagerCampaignDetail() }); // MS Test

            //Assert
            Assert.AreEqual(retVal.OutputResultSource, correctResult.OutputResultSource);
            Assert.AreEqual(retVal.OutputModelResult.TelephoneNumber, correctResult.OutputModelResult.TelephoneNumber);
        }
Ejemplo n.º 9
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);
        }