public void Test_Simple_Desc() { var ts = new TopSelector(); int max = 100; var input = new SimpleTestInput(max); List<WordsFrequency> top = ts.CalcTop(input); int expected = max; foreach(WordsFrequency freq in top) { Console.Out.WriteLine(freq); Assert.AreEqual(expected, freq.Frequency); expected--; } }
public void Test_Complex() { for(int i = 0; i < 100; i++) { var rnd = new Random(); int count = rnd.Next(11, 1000); var input = new RndTestInput(count); var ts = new TopSelector(); List<WordsFrequency> top = ts.CalcTop(input); Assert.AreEqual(TopSelector.TOP_SIZE, top.Count); foreach(WordsFrequency freq in top) Console.Out.WriteLine(freq); int[] frequences = input.Statistic.Select(pair => pair.Value).ToList().OrderByDescending(j => j).ToArray(); int k = 0; foreach(WordsFrequency freq in top) { Console.Out.WriteLine(k); Console.Out.WriteLine(freq); Assert.AreEqual(frequences[k], freq.Frequency, input.Statistic.First(p => p.Value == frequences[k]).ToString()); k++; } } }