Beispiel #1
0
        public void SublocalityTest()
        {
            var locName = "大字";
            var locKana = "オオアザ";
            var subName = "丁目";
            var subKana = "チョウメ";

            using (var sr = new StringReader(
                       LocalityRow(
                           cityCode: CITY_CODE, zipCode: ZIP_CODE,
                           prefectureName: PREF_NAME,
                           prefectureKana: PREF_KANA,
                           cityName: CITY_NAME,
                           cityKana: CITY_KANA,
                           localityName: $"{locName}({subName})",
                           localityKana: $"{locKana}({subKana})")))
                using (var zr = new SublocalityZipcodeReader(sr))
                {
                    AssertNextRow(
                        zr,
                        locName: locName,
                        locKana: locKana,
                        subName: subName,
                        subKana: subKana);

                    Assert.False(zr.MoveNext());
                }
        }
Beispiel #2
0
        public void SplitExceptForTest()
        {
            var locName     = "大字";
            var locKana     = "オオアザ";
            var exceptFor1  = "1丁目";
            var exceptKana1 = "1チョウメ";
            var exceptFor2  = "2丁目";
            var exceptKana2 = "2チョウメ";

            using (var sr = new StringReader(
                       LocalityRow(
                           cityCode: CITY_CODE, zipCode: ZIP_CODE,
                           prefectureName: PREF_NAME,
                           prefectureKana: PREF_KANA,
                           cityName: CITY_NAME,
                           cityKana: CITY_KANA,
                           localityName: $"{locName}({exceptFor1}、{exceptFor2}を除く)",
                           localityKana: $"{locKana}({exceptKana1}、{exceptKana2}ヲノゾク)")))
                using (var zr = new SublocalityZipcodeReader(sr))
                {
                    AssertNextRow(
                        zr,
                        locName: locName,
                        locKana: locKana,
                        exceptFor: exceptFor1 + "、" + exceptFor2,
                        exceptForKana: exceptKana1 + "、" + exceptKana2);

                    Assert.False(zr.MoveNext());
                }
        }
Beispiel #3
0
 public void Test()
 {
     using (var sr = new StreamReader("ADD_1710.CSV", Encoding.GetEncoding(932)))
         using (var zr = new SublocalityZipcodeReader(sr))
         {
             while (zr.MoveNext())
             {
                 _Output.WriteLine($"{zr.CityCode}: {zr.ZipCode7} ({zr.ZipCode5}) {zr.Prefecture} ({zr.PrefectureKana}) {zr.City} ({zr.CityKana}) {zr.Locality} ({zr.LocalityKana}) { zr.Sublocality} ({ zr.SublocalityKana})");
             }
         }
 }
Beispiel #4
0
 private static void AssertNextRow(
     SublocalityZipcodeReader zr,
     string locName   = null, string locKana       = null,
     string subName   = null, string subKana       = null,
     string exceptFor = null, string exceptForKana = null)
 {
     Assert.True(zr.MoveNext());
     Assert.Equal(CITY_CODE, zr.CityCode);
     Assert.Equal(ZIP_CODE, zr.ZipCode7);
     Assert.Equal(PREF_NAME, zr.Prefecture);
     Assert.Equal(PREF_KANA, zr.PrefectureKana);
     Assert.Equal(CITY_NAME, zr.City);
     Assert.Equal(CITY_KANA, zr.CityKana);
     Assert.Equal(locName ?? string.Empty, zr.Locality ?? string.Empty);
     Assert.Equal(locKana ?? string.Empty, zr.LocalityKana ?? string.Empty);
     Assert.Equal(subName ?? string.Empty, zr.Sublocality ?? string.Empty);
     Assert.Equal(subKana ?? string.Empty, zr.SublocalityKana ?? string.Empty);
     Assert.Equal(exceptFor ?? string.Empty, zr.ExceptFor ?? string.Empty);
     Assert.Equal(exceptForKana ?? string.Empty, zr.ExceptForKana ?? string.Empty);
 }
Beispiel #5
0
        public void NoSublocalityTest()
        {
            var locName = "番地";
            var locKana = "バンチ";

            using (var sr = new StringReader(
                       LocalityRow(
                           cityCode: CITY_CODE, zipCode: ZIP_CODE,
                           prefectureName: PREF_NAME,
                           prefectureKana: PREF_KANA,
                           cityName: CITY_NAME,
                           cityKana: CITY_KANA,
                           localityName: locName,
                           localityKana: locKana)))
                using (var zr = new SublocalityZipcodeReader(sr))
                {
                    AssertNextRow(zr, locName: locName, locKana: locKana);

                    Assert.False(zr.MoveNext());
                }
        }