Esempio n. 1
0
        public void InvalidNThrowsExceptionTest()
        {
            // Arrange
            var words           = StringList("a");
            var wordFrequencies = new WordFrequencies(words);
            var numToFind       = 0;

            // Act
            wordFrequencies.GetNthMostOccurring(numToFind);
        }
Esempio n. 2
0
        public void OrderingSkipsValuesTest()
        {
            // Arrange
            var words           = StringList("a", "a", "b", "b", "c");
            var wordFrequencies = new WordFrequencies(words);
            var expected        = StringList("c");
            var numToFind       = 3;

            // Act
            var actual = wordFrequencies.GetNthMostOccurring(numToFind);

            // Assert
            AssertListsAreEqual(expected, actual);
        }
Esempio n. 3
0
        public void TwoWordsSameOccurrencesAreSortedTest()
        {
            // Arrange
            var words           = StringList("a", "a", "b", "b");
            var wordFrequencies = new WordFrequencies(words);
            var expected        = StringList("a", "b");
            var numToFind       = 1;

            // Act
            var actual = wordFrequencies.GetNthMostOccurring(numToFind);

            // Assert
            AssertListsAreEqual(expected, actual);
        }
Esempio n. 4
0
        public void SingleWordWithMultipleOccurrencesTest()
        {
            // Arrange
            var words           = StringList("a", "a");
            var wordFrequencies = new WordFrequencies(words);
            var expected        = StringList("a");
            var numToFind       = 1;

            // Act
            var actual = wordFrequencies.GetNthMostOccurring(numToFind);

            // Assert
            AssertListsAreEqual(expected, actual);
        }
Esempio n. 5
0
        public void InBetweenFrequenciesReturnsNothingTest()
        {
            // Arrange
            var           words           = StringList("a", "a", "b", "b", "c");
            var           wordFrequencies = new WordFrequencies(words);
            List <string> expected        = null;
            var           numToFind       = 2;

            // Act
            var actual = wordFrequencies.GetNthMostOccurring(numToFind);

            // Assert
            AssertListsAreEqual(expected, actual);
        }