Ejemplo n.º 1
0
        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");
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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" }));
        }
Ejemplo n.º 4
0
        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();
        }