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); }
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()); }
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); }
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); }
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); }
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); }
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(); }