Ejemplo n.º 1
0
        public void CodeAll_InputContainMissSpellingsWithDifferentCasingToSavedMatches_AllCodesAdded()
        {
            // arrange
            GeoCoder geoCoder =
                new GeoCoder(MockRepository.GenerateStub <IDbConnection>() as DbConnection);
            InputColumnHeaders     inputColumnHeaders     = InputColumnNames();
            GazetteerColumnHeaders gazetteerColumnHeaders = GazetteerColumnNames();

            //gazetteer data
            string[] names1 = { "P1", "T1", "V1" };
            string[] codes1 = { "1", "10", "100" };

            // saved matched names data
            string[] names2 = { "P1x", "T1x", "V1x" };

            // input data
            // line 1, all names miss-spelt with different casing
            string[] names3 = { "p1x", "t1x", "v1x" };

            InputTestData inputTestData = new InputTestData();

            inputTestData.AddLine(names3);
            geoCoder.SetInputData(inputTestData.Data(inputColumnHeaders));
            geoCoder.SetInputColumns(inputColumnHeaders);

            // create gazetteer data
            GazetteerRecords gazetteerRecords = new GazetteerRecords();

            gazetteerRecords.AddLine(names1, codes1);
            geoCoder.SetGazetteerData(gazetteerRecords.Data(gazetteerColumnHeaders));

            // add records matched names records
            MatchProviderTestData matchProviderTestData = new MatchProviderTestData();

            // add records matching saved matched names to gazetteer names
            matchProviderTestData.AddLevel1(names2, names1);
            matchProviderTestData.AddLevel2(names2, names1);
            matchProviderTestData.AddLevel3(names2, names1);
            MatchProviderStub matchProviderStub = new MatchProviderStub(matchProviderTestData);

            geoCoder.SetMatchProvider(matchProviderStub.MatchProvider());

            geoCoder.SetGazetteerColumns(gazetteerColumnHeaders, false);

            // act
            geoCoder.AddAllLocationCodes();

            // assert
            var columns = geoCoder.LocationCodeColumnHeaders();

            //line 1 - should contain codes 1
            DataRow line1 = geoCoder.InputData.Rows[0];

            Assert.AreEqual(codes1[0], line1[columns.Level1]);
            Assert.AreEqual(codes1[1], line1[columns.Level2]);
            Assert.AreEqual(codes1[2], line1[columns.Level3]);
        }
Ejemplo n.º 2
0
        private MatchProviderStub MatchProviderStubLevel2(string[] inputNames)
        {
            // database contains saved records for level 2 alternate name
            MatchProviderTestData matchProviderTestData = new MatchProviderTestData();

            matchProviderTestData.AddLevel1(inputNames, names1);
            matchProviderTestData.AddLevel2(inputNames, names1);

            MatchProviderStub matchProviderStub =
                new MatchProviderStub(matchProviderTestData);

            matchProviderStub.Alternate = inputNames;
            matchProviderStub.Actual    = names1;
            return(matchProviderStub);
        }
Ejemplo n.º 3
0
        CodeAll_CorrectAndMissSpeltInputWithSavedMatchesForMissSpellings_AllCodesAdded
            ()
        {
            // arrange
            GeoCoder geoCoder =
                new GeoCoder(MockRepository.GenerateStub <IDbConnection>() as DbConnection);
            InputColumnHeaders     inputColumnHeaders     = InputColumnNames();
            GazetteerColumnHeaders gazetteerColumnHeaders = GazetteerColumnNames();

            // create input test data with
            // line 1, all names correct
            // line 2, all names correct
            // line 3, all names miss-spelt
            string[] names1 = { "P1", "T1", "V1" };
            string[] names2 = { "P2", "T2", "V2" };
            string[] names3 = { "P1x", "T1x", "V1x" };
            string[] codes1 = { "1", "10", "100" };
            string[] codes2 = { "2", "20", "200" };

            InputTestData inputTestData = new InputTestData();

            inputTestData.AddLine(names1);
            inputTestData.AddLine(names2);
            inputTestData.AddLine(names3);
            geoCoder.SetInputData(inputTestData.Data(inputColumnHeaders));
            geoCoder.SetInputColumns(inputColumnHeaders);

            // create gazetteer data
            GazetteerRecords gazetteerRecords = new GazetteerRecords();

            gazetteerRecords.AddLine(names1, codes1);
            gazetteerRecords.AddLine(names2, codes2);
            geoCoder.SetGazetteerData(gazetteerRecords.Data(gazetteerColumnHeaders));

            // add records matching input line 3 names to gazetteer names 1
            MatchProviderTestData matchProviderTestData = new MatchProviderTestData();

            matchProviderTestData.AddLevel1(names3, names1);
            matchProviderTestData.AddLevel2(names3, names1);
            matchProviderTestData.AddLevel3(names3, names1);

            MatchProviderStub matchProviderStub = new MatchProviderStub(matchProviderTestData);

            geoCoder.SetMatchProvider(matchProviderStub.MatchProvider());

            geoCoder.SetGazetteerColumns(gazetteerColumnHeaders, false);

            // act
            geoCoder.AddAllLocationCodes();

            // assert
            var columns = geoCoder.LocationCodeColumnHeaders();

            //line 1 - should contain codes 1
            DataRow line1 = geoCoder.InputData.Rows[0];

            Assert.AreEqual(codes1[0], line1[columns.Level1]);
            Assert.AreEqual(codes1[1], line1[columns.Level2]);
            Assert.AreEqual(codes1[2], line1[columns.Level3]);

            //line 2 - should contain codes 2
            DataRow line2 = geoCoder.InputData.Rows[1];

            Assert.AreEqual(codes2[0], line2[columns.Level1]);
            Assert.AreEqual(codes2[1], line2[columns.Level2]);
            Assert.AreEqual(codes2[2], line2[columns.Level3]);

            //line 3 - should contain codes 1
            DataRow line3 = geoCoder.InputData.Rows[2];

            Assert.AreEqual(codes1[0], line3[columns.Level1]);
            Assert.AreEqual(codes1[1], line3[columns.Level2]);
            Assert.AreEqual(codes1[2], line3[columns.Level3]);
        }
        private MatchProviderStub MatchProviderStubLevel3(string[] inputNames)
        {
            // database contains saved record for level 3 alternate name
            MatchProviderTestData matchProviderTestData = new MatchProviderTestData();
            matchProviderTestData.AddLevel1(inputNames, names1);
            matchProviderTestData.AddLevel2(inputNames, names1);
            matchProviderTestData.AddLevel3(inputNames, names1);

            MatchProviderStub matchProviderStub =
                new MatchProviderStub(matchProviderTestData);
            matchProviderStub.Alternate = inputNames;
            matchProviderStub.Actual = names1;
            return matchProviderStub;
        }
        public void CodeAll_CorrectAndMissSpeltInputWithSavedMatchesForMissSpellings_AllCodesAdded()
        {
            // arrange
            GeoCoder geoCoder =
                new GeoCoder(MockRepository.GenerateStub<IDbConnection>() as DbConnection);
            InputColumnHeaders inputColumnHeaders = InputColumnNames();
            GazetteerColumnHeaders gazetteerColumnHeaders = GazetteerColumnNames();

            // create input test data with
            // line 1, all names correct
            // line 2, all names correct
            // line 3, all names miss-spelt
            string[] names1 = {"P1", "T1", "V1"};
            string[] names2 = {"P2", "T2", "V2"};
            string[] names3 = {"P1x", "T1x", "V1x"};
            string[] codes1 = {"1", "10", "100"};
            string[] codes2 = {"2", "20", "200"};

            InputTestData inputTestData = new InputTestData();
            inputTestData.AddLine(names1);
            inputTestData.AddLine(names2);
            inputTestData.AddLine(names3);
            geoCoder.SetInputData(inputTestData.Data(inputColumnHeaders));
            geoCoder.SetInputColumns(inputColumnHeaders);

            // create gazetteer data
            GazetteerRecords gazetteerRecords = new GazetteerRecords();
            gazetteerRecords.AddLine(names1, codes1);
            gazetteerRecords.AddLine(names2, codes2);
            geoCoder.SetGazetteerData(gazetteerRecords.Data(gazetteerColumnHeaders));

            // add records matching input line 3 names to gazetteer names 1
            MatchProviderTestData matchProviderTestData = new MatchProviderTestData();
            matchProviderTestData.AddLevel1(names3, names1);
            matchProviderTestData.AddLevel2(names3, names1);
            matchProviderTestData.AddLevel3(names3, names1);

            MatchProviderStub matchProviderStub = new MatchProviderStub(matchProviderTestData);
            geoCoder.SetMatchProvider(matchProviderStub.MatchProvider());

            geoCoder.SetGazetteerColumns(gazetteerColumnHeaders, false);

            // act
            geoCoder.AddAllLocationCodes();

            // assert
            var columns = geoCoder.LocationCodeColumnHeaders();

            //line 1 - should contain codes 1
            DataRow line1 = geoCoder.InputData.Rows[0];
            Assert.AreEqual(codes1[0], line1[columns.Level1]);
            Assert.AreEqual(codes1[1], line1[columns.Level2]);
            Assert.AreEqual(codes1[2], line1[columns.Level3]);

            //line 2 - should contain codes 2
            DataRow line2 = geoCoder.InputData.Rows[1];
            Assert.AreEqual(codes2[0], line2[columns.Level1]);
            Assert.AreEqual(codes2[1], line2[columns.Level2]);
            Assert.AreEqual(codes2[2], line2[columns.Level3]);

            //line 3 - should contain codes 1
            DataRow line3 = geoCoder.InputData.Rows[2];
            Assert.AreEqual(codes1[0], line3[columns.Level1]);
            Assert.AreEqual(codes1[1], line3[columns.Level2]);
            Assert.AreEqual(codes1[2], line3[columns.Level3]);
        }
        public void CodeAll_InputContainMissSpellingsWithDifferentCasingToSavedMatches_AllCodesAdded()
        {
            // arrange
            GeoCoder geoCoder =
                new GeoCoder(MockRepository.GenerateStub<IDbConnection>() as DbConnection);
            InputColumnHeaders inputColumnHeaders = InputColumnNames();
            GazetteerColumnHeaders gazetteerColumnHeaders = GazetteerColumnNames();

            //gazetteer data
            string[] names1 = { "P1", "T1", "V1" };
            string[] codes1 = { "1", "10", "100" };

            // saved matched names data
            string[] names2 = { "P1x", "T1x", "V1x" };

            // input data
            // line 1, all names miss-spelt with different casing
            string[] names3 = {"p1x", "t1x", "v1x"};

            InputTestData inputTestData = new InputTestData();
            inputTestData.AddLine(names3);
            geoCoder.SetInputData(inputTestData.Data(inputColumnHeaders));
            geoCoder.SetInputColumns(inputColumnHeaders);

            // create gazetteer data
            GazetteerRecords gazetteerRecords = new GazetteerRecords();
            gazetteerRecords.AddLine(names1, codes1);
            geoCoder.SetGazetteerData(gazetteerRecords.Data(gazetteerColumnHeaders));

            // add records matched names records
            MatchProviderTestData matchProviderTestData = new MatchProviderTestData();

            // add records matching saved matched names to gazetteer names
            matchProviderTestData.AddLevel1(names2, names1);
            matchProviderTestData.AddLevel2(names2, names1);
            matchProviderTestData.AddLevel3(names2, names1);
            MatchProviderStub matchProviderStub = new MatchProviderStub(matchProviderTestData);
            geoCoder.SetMatchProvider(matchProviderStub.MatchProvider());

            geoCoder.SetGazetteerColumns(gazetteerColumnHeaders, false);

            // act
            geoCoder.AddAllLocationCodes();

            // assert
            var columns = geoCoder.LocationCodeColumnHeaders();

            //line 1 - should contain codes 1
            DataRow line1 = geoCoder.InputData.Rows[0];
            Assert.AreEqual(codes1[0], line1[columns.Level1]);
            Assert.AreEqual(codes1[1], line1[columns.Level2]);
            Assert.AreEqual(codes1[2], line1[columns.Level3]);
        }