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

            // Act
            wordFrequencies.GetNthMostOccurring(numToFind);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }