Example #1
0
        public void SortAlphabetically_RemoveAllPunctuationsFromTheEnd()
        {
            // Arrange
            var          sut  = new TextSorter();
            const string text = "a! b\" c# d$ e% f& g' h( i) l* m+ n, o- p. q/ r: s; t? u@ v[ w\\ x] y^ z_ aa` bb{ cc| dd} ee~ ";

            // Act
            var result = sut.Sort(text, SortOption.Alphabetically);

            // Assert
            var expected = new List <string>
            {
                "a", "aa", "b", "bb", "c", "cc", "d", "dd", "e", "ee", "f", "g", "h", "i", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
            };

            expected.Should().BeEquivalentTo(result);
        }
Example #2
0
        public void SortBySentenceLength()
        {
            // Arrange
            var          sut  = new TextSorter();
            const string text = "Short sentence. This a longer sentence.";

            // Act
            var result = sut.Sort(text, SortOption.BySentenceLength);

            // Assert
            var expected = new List <string>
            {
                "Short sentence",
                "This a longer sentence"
            };

            expected.Should().BeEquivalentTo(result);
        }
Example #3
0
        public void SortByWordLength()
        {
            // Arrange
            var          sut  = new TextSorter();
            const string text = "cc b aaa";

            // Act
            var result = sut.Sort(text, SortOption.ByWordLength);

            // Assert
            var expected = new List <string>
            {
                "b",
                "cc",
                "aaa",
            };

            expected.Should().BeEquivalentTo(result);
        }
Example #4
0
        public void SortAlphabetically_SetOfCharactersWithDot()
        {
            // Arrange
            var          sut  = new TextSorter();
            const string text = "d e. A";

            // Act
            var result = sut.Sort(text, SortOption.Alphabetically);

            // Assert
            var expected = new List <string>
            {
                "A",
                "d",
                "e"
            };

            expected.Should().BeEquivalentTo(result);
        }
Example #5
0
        public void SortAlphabetically_SetOfWordsWithSingleQuote()
        {
            // Arrange
            var          sut  = new TextSorter();
            const string text = "A sentence' with an hyphen";

            // Act
            var result = sut.Sort(text, SortOption.Alphabetically);

            // Assert
            var expected = new List <string>
            {
                "A",
                "an",
                "hyphen",
                "sentence",
                "with"
            };

            expected.Should().BeEquivalentTo(result);
        }
Example #6
0
        public void SortAlphabetically_SentenceWithSpace()
        {
            // Arrange
            var          sut  = new TextSorter();
            const string text = "This is the text to be sorted";

            // Act
            var result = sut.Sort(text, SortOption.Alphabetically);

            // Assert
            var expected = new List <string>
            {
                "be",
                "is",
                "sorted",
                "text",
                "the",
                "This",
                "to"
            };

            expected.Should().BeEquivalentTo(result);
        }
Example #7
0
        public void SortAlphabetically_SetOfCharactersSeparatedBySpace()
        {
            // Arrange
            var          sut  = new TextSorter();
            const string text = "a b c d e f g";

            // Act
            var result = sut.Sort(text, SortOption.Alphabetically);

            // Assert
            var expected = new List <string>
            {
                "a",
                "b",
                "c",
                "d",
                "e",
                "f",
                "g"
            };

            expected.Should().BeEquivalentTo(result);
        }