コード例 #1
0
        public void AddingWordCountToDictTest()
        {
            //Testing function that adds the number of occurences of each word that appears in the file
            //to the dictionary in the int value corresponding to the key (word).
            FormStatistics f  = new FormStatistics();
            List <string>  s1 = new List <string>()
            {
                "hello", "the", "world", "the", "hello", "world", "my", "the"
            };
            List <string> s2 = new List <string>()
            {
                "hello", "the", "world", "my"
            };
            Dictionary <string, int> d1 = new Dictionary <string, int>()
            {
                { "hello", 0 }, { "the", 0 }, { "world", 0 }, { "my", 0 }
            };
            Dictionary <string, int> expected = new Dictionary <string, int>()
            {
                { "hello", 2 }, { "the", 3 }, { "world", 2 }, { "my", 1 }
            };
            Dictionary <string, int> actual = new Dictionary <string, int>();

            actual = f.AddingWordCountToDict(s1, s2, d1);
            CollectionAssert.AreEquivalent(expected, actual);
        }
コード例 #2
0
ファイル: FormMenu'.cs プロジェクト: PhatosGames/Sear
        private void btn_StatisticsOpen_Click(object sender, EventArgs e)
        {
            this.Hide();
            FormStatistics dis = new FormStatistics();

            dis.ShowDialog();
        }
コード例 #3
0
        public void ShortestWordsTest()
        {
            //Testing function that returns a dictionary of all the shortest words in the file.
            FormStatistics f  = new FormStatistics();
            List <string>  s1 = new List <string>()
            {
                "hello", "my", "hello", "world"
            };
            List <string> s2 = new List <string>()
            {
                "hello", "my", "world"
            };
            Dictionary <string, int> d1 = new Dictionary <string, int>()
            {
                { "hello", 5 }, { "my", 2 }, { "world", 5 }
            };
            Dictionary <string, int> expected = new Dictionary <string, int>()
            {
                { "my", 2 }
            };

            Dictionary <string, int> actual = new Dictionary <string, int>();

            actual = f.ShortestWords(s1, s2, d1);
            CollectionAssert.AreEquivalent(expected, actual);
        }
コード例 #4
0
        public void MostCommonWordsTest()
        {
            //Testing function that finds all the words that appear the most in the file
            FormStatistics f  = new FormStatistics();
            List <string>  s1 = new List <string>()
            {
                "hello", "world", "hello", "world", "hello"
            };
            List <string> s2 = new List <string>()
            {
                "hello", "world"
            };
            Dictionary <string, int> d1 = new Dictionary <string, int>()
            {
                { "hello", 3 }, { "world", 2 }
            };
            Dictionary <string, int> expected = new Dictionary <string, int>()
            {
                { "hello", 3 }
            };

            Dictionary <string, int> actual = new Dictionary <string, int>();

            actual = f.MostCommonWords(s1, s2, d1);
            CollectionAssert.AreEquivalent(expected, actual);
        }
コード例 #5
0
ファイル: FormOrder.cs プロジェクト: PhatosGames/Sear
        private void btn_Statistics_Click(object sender, EventArgs e)
        {
            this.Hide();
            FormStatistics stat = new FormStatistics();

            stat.ShowDialog();
            this.Close();
        }
コード例 #6
0
        private void 统计ToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            //新创建统计窗体
            FormStatistics formStatistics = new FormStatistics();

            //将当前主窗体中MapControl控件中的Map对象赋值给FormStatistics窗体的CurrentMap属性
            formStatistics.CurrentMap = axMapControl1.Map;
            //显示统计窗体
            formStatistics.Show();
        }
コード例 #7
0
        public void SearchLengthTest()
        {
            //Testing function if no words with the length entered are in the file
            FormStatistics f        = new FormStatistics();
            int            i1       = 5;
            string         expected = "there is no words in the text with 5 letters.";
            string         actual   = f.SearchLength(i1);

            Assert.AreEqual(expected, actual);
        }
コード例 #8
0
        public void SearchWordOccurenceTest()
        {
            //Testing function if string entered is not in the file
            FormStatistics f        = new FormStatistics();
            string         s1       = "hello";
            string         expected = "hello does not appear in the text.";
            string         actual   = f.SearchWordOccurence(s1);

            Assert.AreEqual(expected, actual);
        }
コード例 #9
0
        public void SortListTest()
        {
            //Testing function that returns the list sorted
            FormStatistics f  = new FormStatistics();
            List <string>  s1 = new List <string>()
            {
                { "hello" }, { "world" }, { "the" }
            };
            string expected = "hello, the, world ";
            string actual   = f.SortList(s1);

            Assert.AreEqual(expected, actual);
        }
コード例 #10
0
        public void DisplayKeysTest()
        {
            //Testing function that returns a string of all unique words in the file
            FormStatistics           f  = new FormStatistics();
            Dictionary <string, int> d1 = new Dictionary <string, int>()
            {
                { "hello", 4 }, { "world", 4 }
            };
            string expected = "hello, world ";
            string actual   = f.DisplayKeys(d1);

            Assert.AreEqual(expected, actual);
        }
コード例 #11
0
        public void DisplayStatsTest()
        {
            //Testing function that returns the correct stat to display
            FormStatistics           f  = new FormStatistics();
            Dictionary <string, int> d1 = new Dictionary <string, int>()
            {
                { "hello", 2 }, { "world", 4 }
            };
            string expected = "Frequency: 4 letters." + Environment.NewLine;
            string actual   = f.DisplayStats("Frequency", d1, "max", "letters.");

            Assert.AreEqual(expected, actual);
        }
コード例 #12
0
        public void AverageWordLengthTest()
        {
            //Testing function that calculates the average word length of unique words only
            FormStatistics f  = new FormStatistics();
            List <string>  s1 = new List <string>()
            {
                "hello", "my", "world"
            };
            double expected = 4.00;
            double actual   = f.AverageWordLength(s1);

            Assert.AreEqual(expected, actual);
        }
コード例 #13
0
        public void ConvertListToDictionaryTest()
        {
            //Testing function for converting a list into a dictionary with 0 values for the int
            FormStatistics f  = new FormStatistics();
            List <string>  s1 = new List <string>()
            {
                "hello", "world"
            };
            Dictionary <string, int> expected = new Dictionary <string, int>()
            {
                { "hello", 0 }, { "world", 0 }
            };
            Dictionary <string, int> actual = new Dictionary <string, int>();

            actual = f.ConvertListToDictionary(s1);
            CollectionAssert.AreEquivalent(expected, actual);
        }
コード例 #14
0
        public void UniqueWordsTest()
        {
            //Testing function for creating a list of unique words.
            FormStatistics f  = new FormStatistics();
            List <string>  s1 = new List <string>()
            {
                "hello", "world", "hello", "world"
            };
            List <string> expected = new List <string>()
            {
                "hello", "world"
            };
            List <string> actual = new List <string>();

            actual = f.UniqueWords(s1);
            CollectionAssert.AreEquivalent(expected, actual);
        }
コード例 #15
0
        public void AddWordLengthToDictTest()
        {
            //Testing function that adds the word length to the dictionary in the int value
            //corresponding to the key (word).
            FormStatistics f  = new FormStatistics();
            List <string>  s1 = new List <string>()
            {
                "hello", "the", "world", "my"
            };
            Dictionary <string, int> d1 = new Dictionary <string, int>()
            {
                { "hello", 0 }, { "the", 0 }, { "world", 0 }, { "my", 0 }
            };
            Dictionary <string, int> expected = new Dictionary <string, int>()
            {
                { "hello", 5 }, { "the", 3 }, { "world", 5 }, { "my", 2 }
            };
            Dictionary <string, int> actual = new Dictionary <string, int>();

            actual = f.AddWordLengthToDict(s1, d1);
            CollectionAssert.AreEquivalent(expected, actual);
        }