Exemplo n.º 1
0
        public void WordPairGroups_InputThreeIdenticalWords_ReturnsOneCollectionItemWithTwoCounts()
        {
            IEnumerable <WordPair> expected = new WordPair[] { new WordPair()
                                                               {
                                                                   Text = "quick quick", Count = 2
                                                               } };

            IEnumerable <string> words = new List <string> {
                "quick", "quick", "quick"
            };
            IEnumerable <WordPair> actual = histogram.GetWordPairGroups(words);

            Assert.That(expected.Select(wpSelector), Is.EquivalentTo(actual.Select(wpSelector)));
        }
Exemplo n.º 2
0
        public void WordPairGroups_InputTwoDifferentWords_ReturnsOneCollectionItemWithOneCount()
        {
            IEnumerable <WordPair> expected = new WordPair[] { new WordPair()
                                                               {
                                                                   Text = "quick brown", Count = 1
                                                               } };

            IEnumerable <string> words = new List <string> {
                "quick", "brown"
            };
            IEnumerable <WordPair> actual = histogram.GetWordPairGroups(words);

            Assert.That(expected.Select(wpSelector), Is.EquivalentTo(actual.Select(wpSelector)));
        }
Exemplo n.º 3
0
        public void WordPairGroups_InputTwoIdenticalWords_ReturnsOneCollectionItemWithOneCount()
        {
            IEnumerable <WordPair> expected = new WordPair[] { new WordPair()
                                                               {
                                                                   Text = "quick quick", Count = 1
                                                               } };

            IEnumerable <string> words = new List <string> {
                "quick", "quick"
            };
            IEnumerable <WordPair> actual = histogram.GetWordPairGroups(words);

            // Could not compare the two lists directly using Assert.AreEqual.
            // Used transform function as a workaround.
            Assert.That(expected.Select(wpSelector), Is.EquivalentTo(actual.Select(wpSelector)));
        }
Exemplo n.º 4
0
        public void WordPairGroups_InputRepeatedAdjacentWord_ReturnsTwoCountsForThatCollectionItem()
        {
            IEnumerable <WordPair> expected = new WordPair[] {
                new WordPair()
                {
                    Text = "the quick", Count = 2
                },
                new WordPair()
                {
                    Text = "quick brown", Count = 1
                },
                new WordPair()
                {
                    Text = "brown fox", Count = 1
                },
                new WordPair()
                {
                    Text = "fox and", Count = 1
                },
                new WordPair()
                {
                    Text = "and the", Count = 1
                },
                new WordPair()
                {
                    Text = "quick blue", Count = 1
                },
                new WordPair()
                {
                    Text = "blue hare", Count = 1
                }
            };

            IEnumerable <string> words = new List <string> {
                "the", "quick", "brown", "fox", "and", "the", "quick", "blue", "hare"
            };
            IEnumerable <WordPair> actual = histogram.GetWordPairGroups(words);

            Assert.That(expected.Select(wpSelector), Is.EquivalentTo(actual.Select(wpSelector)));
        }