Exemple #1
0
        public void findshortest()
        {
            Sort   sort   = new Sort();
            Sorted sorted = new Sorted();

            sorted = sort.shortest("A cow jumped over the moon");
            Assert.Equal("A", sorted.Word);
            Assert.Equal(1, sorted.Length);
        }
Exemple #2
0
        public void multipleSpaceBetweenWords()
        {
            Sort   sort   = new Sort();
            Sorted sorted = new Sorted();

            sorted = sort.shortest("The  cow  jumped  over  the  moon");
            Assert.Equal("", sorted.Word);
            Assert.Equal(0, sorted.Length);
        }
Exemple #3
0
        public void apostrophesIncludedInWordLength()
        {
            Sort   sort   = new Sort();
            Sorted sorted = new Sorted();

            sorted = sort.shortest("A' cow didn't jump over the moon");
            Assert.Equal("A'", sorted.Word);
            Assert.Equal(2, sorted.Length);
        }
Exemple #4
0
        public void numbersTreatedAsWords()
        {
            Sort   sort   = new Sort();
            Sorted sorted = new Sorted();

            sorted = sort.shortest("1 cow jumped over the moon");
            Assert.Equal("1", sorted.Word);
            Assert.Equal(1, sorted.Length);
        }
Exemple #5
0
        public void multipleWordsOfshortestLength()
        {
            Sort   sort   = new Sort();
            Sorted sorted = new Sorted();

            sorted = sort.shortest("The cow jumped over the moon");
            Assert.Equal("The", sorted.Word);
            Assert.Equal(3, sorted.Length);
        }
Exemple #6
0
        public void underScoresIncludedInWordLength()
        {
            Sort   sort   = new Sort();
            Sorted sorted = new Sorted();

            sorted = sort.shortest("A_ cow jumped over the new_moon");
            Assert.Equal("A_", sorted.Word);
            Assert.Equal(2, sorted.Length);
        }
        public void findLongest()
        {
            Sort   sort   = new Sort();
            Sorted sorted = new Sorted();

            sorted = sort.longest("The cow jumped over the moon");
            Assert.Equal("jumped", sorted.Word);
            Assert.Equal(6, sorted.Length);
        }
Exemple #8
0
        public void emptyString()
        {
            Sort   sort   = new Sort();
            Sorted sorted = new Sorted();

            sorted = sort.shortest("");
            Assert.Equal("", sorted.Word);
            Assert.Equal(0, sorted.Length);
        }
        public void numbersTreatedAsWords()
        {
            Sort   sort   = new Sort();
            Sorted sorted = new Sorted();

            sorted = sort.longest("1234567 cows jumped over the moon");
            Assert.Equal("1234567", sorted.Word);
            Assert.Equal(7, sorted.Length);
        }
Exemple #10
0
        public void apostrophesIncludedInWordLength()
        {
            Sort   sort   = new Sort();
            Sorted sorted = new Sorted();

            sorted = sort.longest("The cow didn't jump over the moon");
            Assert.Equal("didn't", sorted.Word);
            Assert.Equal(6, sorted.Length);
        }
Exemple #11
0
        public void multipleWordsOfLongestLength()
        {
            Sort   sort   = new Sort();
            Sorted sorted = new Sorted();

            sorted = sort.longest("The better cow jumped over the moon");
            Assert.Equal("better", sorted.Word);
            Assert.Equal(6, sorted.Length);
        }
Exemple #12
0
        public Sorted longest(string sentence)
        {
            string[] wordList = splitter(sentence);
            var      biggest  = wordList.OrderByDescending(n => n.Length).First();
            Sorted   sorted   = new Sorted();

            sorted.Word   = biggest;
            sorted.Length = biggest.Length;
            return(sorted);
        }
Exemple #13
0
        public Sorted shortest(string sentence)
        {
            string[] wordList = splitter(sentence);
            var      smallest = wordList.OrderBy(n => n.Length).First();
            Sorted   sorted   = new Sorted();

            sorted.Word   = smallest;
            sorted.Length = smallest.Length;
            return(sorted);
        }