Exemplo 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");
        }
Exemplo 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);
        }
Exemplo n.º 3
0
        public PrefixReader(TextReader reader)
        {
            this.reader = reader;

            //получение экземляра класса, реализующего интерфейс IPrefixStorage
            storage = InjectContainer.Instance.Get <IPrefixStorage>();

            //чтение слов найденных в текстах
            var wordCount = Convert.ToInt32(reader.ReadLine());

            while (wordCount-- > 0)
            {
                storage.Add(reader.ReadLine());
            }
        }
Exemplo n.º 4
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" }));
        }