public static List <GazetteerRecord> TestData1()
        {
            GazetteerRecords gazetteerRecords = new GazetteerRecords();

            // P1, T1, V1, P1A, T1A, V1A
            gazetteerRecords.AddLine(Names1, Codes0, AltNames1);
            // P1, T1, V2, "","",""
            gazetteerRecords.AddLine(Names2, Codes0, AltNamesEmpty);
            // P2, T2, V1, P2A, T2A, V1A
            gazetteerRecords.AddLine(Names3, Codes0, AltNames3);
            // P2, T2, V2,
            gazetteerRecords.AddLine(Names4, Codes0);
            // P2, T2, V3,
            gazetteerRecords.AddLine(Names5, Codes0);
            // P1, T2, V1, P1A, T2A, V1A,
            gazetteerRecords.AddLine(Names6, Codes0, AltNames4);
            // P1, T2, V4
            gazetteerRecords.AddLine(Names7, Codes0);
            // P2, T1, V2
            gazetteerRecords.AddLine(Names8, Codes0);
            // ' P3 ', ' T3 ', ' V3 '
            gazetteerRecords.AddLine(Names9, Codes0);

            return(gazetteerRecords.GadmList());
        }
Example #2
0
        GetLocationCodes_GazContainsDuplicateCombinedLevel2And3_CorrectCodesAdded()
        {
            // Arrange
            // gazetteer data
            GazetteerRecords gazetteerRecords = GazetteerTestData();

            // input data -
            string[] inputNames = { "P1", "T1V", "1" }; // names 4
            Location location   = new Location(
                inputNames[0],
                inputNames[1],
                inputNames[2]);

            // no saved matches
            MatchProviderStub matchProviderStub = MatchProviderStubEmpty(inputNames);

            Coder coder = new Coder(
                gazetteerRecords.GadmList(),
                matchProviderStub.MatchProvider());

            // Act
            CodedLocation codedLocation = coder.GetCodes(location);

            // Assert
            // correct codes added (codes 4)
            Assert.AreEqual(codes4[0], codedLocation.GeoCode1.Code);
            Assert.AreEqual(codes4[1], codedLocation.GeoCode2.Code);
            Assert.AreEqual(codes4[2], codedLocation.GeoCode3.Code);
        }
Example #3
0
        public void GetCodes_Leve1And3CorrectAndLevel2HasSavedMatch_AllCodesAdded()
        {
            // Arrange
            // gazetteer data - contains codes for names1 and names2
            GazetteerRecords gazetteerRecords = GazetteerTestData();

            // input data - level 2 miss-spelt
            string[] inputNames = { "P1", "T1x", "V1" };
            Location location   = new Location(
                inputNames[0],
                inputNames[1],
                inputNames[2]);

            //saved matches
            MatchProviderStub matchProviderStub = MatchProviderStubLevel2(inputNames);

            Coder coder = new Coder(
                gazetteerRecords.GadmList(),
                matchProviderStub.MatchProvider());

            // Act
            CodedLocation codedLocation = coder.GetCodes(location);

            // Assert
            // code 1, 2 and 3 codes added
            Assert.AreEqual(codes1[0], codedLocation.GeoCode1.Code);
            Assert.AreEqual(names1[0], codedLocation.GeoCode1.Name);
            Assert.AreEqual(codes1[1], codedLocation.GeoCode2.Code);
            Assert.AreEqual(names1[1], codedLocation.GeoCode2.Name);
            Assert.AreEqual(codes1[2], codedLocation.GeoCode3.Code);
            Assert.AreEqual(names1[2], codedLocation.GeoCode3.Name);
        }
Example #4
0
        public void GetLocationCodes_Level1Incorrect_NoCodesAdded()
        {
            // Arrange
            // gazetteer data - contains codes for names1 and names2
            GazetteerRecords gazetteerRecords = GazetteerTestData();

            // input data - level 2 miss-spelt
            string[] inputNames = { "P1x", "T1", "V1" };
            Location location   = new Location(
                inputNames[0],
                inputNames[1],
                inputNames[2]);

            // no saved matches
            MatchProviderStub matchProviderStub = MatchProviderStubEmpty(inputNames);

            Coder coder = new Coder(
                gazetteerRecords.GadmList(),
                matchProviderStub.MatchProvider());

            // Act
            CodedLocation codedLocation = coder.GetCodes(location);

            // Assert
            // no codes added
            Assert.AreEqual(null, codedLocation.GeoCode1);
            Assert.AreEqual(null, codedLocation.GeoCode2);
            Assert.AreEqual(null, codedLocation.GeoCode3);
        }
Example #5
0
        public void GetLocationCodes_Level1Correct_Level1CodeAdded()
        {
            // Arrange
            // gazetteer data - contains codes for names1 and names2
            GazetteerRecords gazetteerRecords = GazetteerTestData();

            // input data - no level 3 supplied
            string[] inputNames = { "P1", null, null };
            Location location   = new Location(
                inputNames[0]);

            // no saved matches
            MatchProviderStub matchProviderStub = MatchProviderStubEmpty(inputNames);

            Coder coder = new Coder(
                gazetteerRecords.GadmList(),
                matchProviderStub.MatchProvider());

            // Act
            CodedLocation codedLocation = coder.GetCodes(location);

            // Assert
            // level 1 code only added
            Assert.AreEqual(codes1[0], codedLocation.GeoCode1.Code);
            Assert.AreEqual(names1[0], codedLocation.GeoCode1.Name);
            Assert.AreEqual(null, codedLocation.GeoCode2);
            Assert.AreEqual(null, codedLocation.GeoCode3);
        }
Example #6
0
        GetLocationCodes_Leve1And2CorrectAndLevel3Incorrect_Level1And2CodeAddedOnly()
        {
            // Arrange
            // gazetteer data - contains codes for names1 and names2
            GazetteerRecords gazetteerRecords = GazetteerTestData();

            // input data - level 3 miss-spelt
            string[] inputNames = { "P1", "T1", "V1x" };
            Location location   = new Location(
                inputNames[0],
                inputNames[1],
                inputNames[2]);

            // no saved matches
            MatchProviderStub matchProviderStub = MatchProviderStubEmpty(inputNames);

            Coder coder = new Coder(
                gazetteerRecords.GadmList(),
                matchProviderStub.MatchProvider());

            // Act
            CodedLocation codedLocation = coder.GetCodes(location);

            // Assert
            // code 1 and 2 only are added, no level 3 code added
            Assert.AreEqual(codes1[0], codedLocation.GeoCode1.Code);
            Assert.AreEqual(names1[0], codedLocation.GeoCode1.Name);
            Assert.AreEqual(codes1[1], codedLocation.GeoCode2.Code);
            Assert.AreEqual(names1[1], codedLocation.GeoCode2.Name);
            Assert.AreEqual(null, codedLocation.GeoCode3);
        }
Example #7
0
        private GazetteerRecords GazetteerTestData(string[] altNames)
        {
            GazetteerRecords gazetteerRecords = new GazetteerRecords();

            gazetteerRecords.AddLine(names1, codes1, altNames);
            gazetteerRecords.AddLine(names2, codes2, altNames);
            return(gazetteerRecords);
        }
Example #8
0
        private GazetteerRecords GazetteerTestData()
        {
            GazetteerRecords gazetteerRecords = new GazetteerRecords();

            gazetteerRecords.AddLine(names1, codes1);
            gazetteerRecords.AddLine(names2, codes2);
            return(gazetteerRecords);
        }
Example #9
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]);
        }
Example #10
0
        public void GetLocationCodes_Level1GazetteerAltName_AllCodesAdded()
        {
            // Arrange
            // gazetteer data - contains codes for names1 and names2 and
            // an alternate name for name1
            string[]         altNames         = { "P1A", null, null };
            GazetteerRecords gazetteerRecords = GazetteerTestData(altNames);

            //
            gazetteerRecords.AddLine(names2, codes2);

            // input data - Level1 contains alt spelling, the rest are spelt correctly
            string[] inputNames = { "P1A", "T1", "V1" };
            Location location   = new Location(
                inputNames[0],
                inputNames[1],
                inputNames[2]);

            // no saved matches
            MatchProviderStub matchProviderStub = MatchProviderStubEmpty(inputNames);

            Coder coder = new Coder(
                gazetteerRecords.GadmList(),
                matchProviderStub.MatchProvider());

            // Act
            CodedLocation codedLocation = coder.GetCodes(location);

            // Assert
            // code 1, 2 and 3 codes added
            Assert.AreEqual(codes1[0], codedLocation.GeoCode1.Code);
            Assert.AreEqual(names1[0], codedLocation.GeoCode1.Name);
            Assert.AreEqual(codes1[1], codedLocation.GeoCode2.Code);
            Assert.AreEqual(names1[1], codedLocation.GeoCode2.Name);
            Assert.AreEqual(codes1[2], codedLocation.GeoCode3.Code);
            Assert.AreEqual(names1[2], codedLocation.GeoCode3.Name);
        }
        public static List<GazetteerRecord> TestData1()
        {
            GazetteerRecords gazetteerRecords = new GazetteerRecords();
            // P1, T1, V1, P1A, T1A, V1A
            gazetteerRecords.AddLine(Names1, Codes0, AltNames1);
            // P1, T1, V2, "","",""
            gazetteerRecords.AddLine(Names2, Codes0, AltNamesEmpty);
            // P2, T2, V1, P2A, T2A, V1A
            gazetteerRecords.AddLine(Names3, Codes0, AltNames3);
            // P2, T2, V2,
            gazetteerRecords.AddLine(Names4, Codes0);
            // P2, T2, V3,
            gazetteerRecords.AddLine(Names5, Codes0);
            // P1, T2, V1, P1A, T2A, V1A,
            gazetteerRecords.AddLine(Names6, Codes0, AltNames4);
            // P1, T2, V4
            gazetteerRecords.AddLine(Names7, Codes0);
            // P2, T1, V2
            gazetteerRecords.AddLine(Names8, Codes0);
            // ' P3 ', ' T3 ', ' V3 '
            gazetteerRecords.AddLine(Names9, Codes0);

            return gazetteerRecords.GadmList();
        }
Example #12
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 GazetteerRecords GazetteerTestData(string[] altNames)
 {
     GazetteerRecords gazetteerRecords = new GazetteerRecords();
     gazetteerRecords.AddLine(names1, codes1, altNames);
     gazetteerRecords.AddLine(names2, codes2, altNames);
     return gazetteerRecords;
 }
Example #14
0
 private GazetteerRecords GazetteerTestData()
 {
     GazetteerRecords gazetteerRecords = new GazetteerRecords();
     gazetteerRecords.AddLine(names1, codes1);
     gazetteerRecords.AddLine(names2, codes2);
     gazetteerRecords.AddLine(names3, codes3);
     gazetteerRecords.AddLine(names4, codes4);
     return gazetteerRecords;
 }
        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]);
        }