コード例 #1
0
ファイル: Program.cs プロジェクト: mokeev1995/LaboratoryWorks
 private static void PrintResults(FreqResult res)
 {
     Console.WriteLine();
     Console.WriteLine($"Всего найдено {res.Count} уникальных слов, из которых самые частые: ");
     foreach (var keyValuePair in res.TopResults)
     {
         Console.WriteLine($"\t{keyValuePair.Key}\t: {keyValuePair.Value} повторов");
     }
 }
コード例 #2
0
        public void DictFreq_Test()
        {
            var dict = new DictFreq();
            var data = dict.GetCount(_words);

            var expected = new FreqResult(12,
                new[]
                {
                    new KeyValuePair<string, int>("test", 3),
                    new KeyValuePair<string, int>("test1", 2),
                    new KeyValuePair<string, int>("asd", 1),
                    new KeyValuePair<string, int>("das", 1),
                    new KeyValuePair<string, int>("aaaa", 1),
                    new KeyValuePair<string, int>("dsada", 1),
                    new KeyValuePair<string, int>("qwe", 1),
                    new KeyValuePair<string, int>("rty", 1),
                    new KeyValuePair<string, int>("hgf", 1),
                    new KeyValuePair<string, int>("ghjkghjk", 1)
                });

            Assert.AreEqual(true, FirstEqual(expected.TopResults, data.TopResults, 2));
            Assert.AreEqual(expected.Count, data.Count);
        }