public void AddTest() { IPrefixStorage target = InjectContainer.Instance.Get <IPrefixStorage>(); target.Add("example 0"); Assert.AreEqual(target.Lookup("").Single(), "example"); target.Add("examination 1"); Assert.AreEqual(target.Lookup("").Last(), "example"); Assert.AreEqual(target.Lookup("exam").First(), "examination"); }
public void EmptyLookupTest() { IPrefixStorage target = InjectContainer.Instance.Get <IPrefixStorage>(); target.Add("example 0"); target.Add("exist 3"); target.Add("examination 1"); target.Add("exercise 2"); target.Add("ecology 5"); target.Add("exam 10"); target.Add("exa 11"); string[] actual = target.Lookup("tetris"); Assert.AreEqual(0, actual.Length); }
public void LookupTest() { IPrefixStorage target = InjectContainer.Instance.Get <IPrefixStorage>(); target.Add("example 0"); target.Add("exist 3"); target.Add("examination 1"); target.Add("exercise 2"); target.Add("ecology 5"); target.Add("tetris 7"); target.Add("exam 10"); target.Add("exa 11"); string[] actual = target.Lookup("exam"); Assert.AreEqual(3, actual.Length); Assert.IsTrue(actual.SequenceEqual(new[] { "exam", "examination", "example" })); }
public void Process(TextWriter writer) { //чтение слов, введенных пользователем var prefixCount = Convert.ToInt32(reader.ReadLine()); while (prefixCount-- > 0) { //поиск слов, удовлетворяющих запросу var words = storage.Lookup(reader.ReadLine()); foreach (var word in words) { writer.WriteLine(word); } writer.WriteLine(); } writer.Flush(); }