Ejemplo n.º 1
0
        public void FreqGeneratesCorrectly()
        {
            var bytes = Encoding.ASCII.GetBytes(THE_QBF);
            var freq  = new FrequencyAnalysis(bytes, FreqTableType.AlphaOnly);
            var list  = freq.GetFrequencyCounts().ToArray();

            Assert.AreEqual(1, list[97], "# A incorrect");
            Assert.AreEqual(4, list[111], "# O incorrect");
            var vals = list.Where(n => n > 0).ToArray();

            CollectionAssert.AreEqual(QBF_COUNTS, vals, "Final counts are incorrect");
            double letterAPct  = freq.GetFrequencyPctByChar('a');
            double letterAPct2 = freq.GetFrequencyPctByChar('A');

            Assert.AreEqual(letterAPct, letterAPct2, "Letter A and letter a not equal");
            Assert.AreEqual(Math.Round(100.0 / (double)THE_QBF.Length, 5), letterAPct, "Letter A not 1/43 freq");
        }