public void GetRegions() { var list = GetAllRegions(); var source = new AddressParser(Log, FolderWithLucene); foreach (var part in source.GetByLevel("010000000000000")) { Assert.IsTrue(list.ContainsKey(part.Id)); var d = list[part.Id]; Assert.That(part.Id, Is.EqualTo(d.Code)); Assert.That(part.NameWithReduction, Is.EqualTo(d.Name)); } }
public void GetByLevel() { var source = new AddressParser(Log, FolderWithLucene); var list = new string[] { // 1 "090000000000000", "890000000000000", // 2 "110070000000000", "140280000000000", "660120000000000", // 3 "020000030000000", "240020080000000", "540060040000000", // 4 "500000360000000", "470130009190000", "010000010080000", "590190000480000", "710240002550000", }; long total = 0; int count = 0; for (int i = 0; i < 10; i++) { foreach (var code in list) { count++; var b = DateTime.UtcNow.Ticks; int level = source.GetLevel(code).Value; var collection = source.GetByLevel(code); System.Diagnostics.Trace.WriteLine(code + "..."); int? totalHits = null; foreach (var d in collection) { if (!totalHits.HasValue) { totalHits = d.LastInfo.TotalHits; System.Diagnostics.Trace.WriteLine("TotalHits: " + totalHits); } if (totalHits < 20) System.Diagnostics.Trace.WriteLine(" " + d.ToString()); try { Assert.That(d.Level, Is.EqualTo(level)); } catch (Exception) { System.Diagnostics.Trace.WriteLine("warn:" + d.ToString()); throw; } } total += (DateTime.UtcNow.Ticks - b); } } System.Diagnostics.Trace.WriteLine(string.Format("Total: {0} ms", 1.0 * total / (TimeSpan.TicksPerMillisecond * count))); }