public void ReturnShortestWordContainingNumbers()
        {
            Sentence sentence = new Sentence();

            ShortestWord result = sentence.FindShortestWord("The 2 cows jumper over moon");

            Assert.Equal("2", result.Word);
        }
        public void ReturnShortestWordIgnoringSpacesAtTheEnd()
        {
            Sentence sentence = new Sentence();

            ShortestWord result = sentence.FindShortestWord("Amazing glittering cattle jumps   ");

            Assert.Equal("jumps", result.Word);
        }
        public void ReturnZeroShortestWordLengthWordWhenEmptySentence()
        {
            Sentence sentence = new Sentence();

            ShortestWord result = sentence.FindShortestWord("");

            Assert.Equal(0, result.Length);
        }
        public void ReturnShortestWordContainingSpecialCharacters()
        {
            Sentence sentence = new Sentence();

            ShortestWord result = sentence.FindShortestWord("Loremipsumdolorsitametconsecteturadipiscingelitportaconsequat !@#$%^&*()_+={}[]:;'<>?/`~\"\\");

            Assert.Equal("!@#$%^&*()_+={}[]:;'<>?/`~\"\\", result.Word);
        }
        public void ReturnFirstShortestWordWhenMoreThanOneLongest()
        {
            Sentence sentence = new Sentence();

            ShortestWord result = sentence.FindShortestWord("The cow jumps over the sandy beach");

            Assert.Equal("The", result.Word);
        }
        public void ReturnEmptyShortestWordWhenEmptySentence()
        {
            Sentence sentence = new Sentence();

            ShortestWord result = sentence.FindShortestWord("");

            Assert.Equal("", result.Word);
        }
        public void ReturnShortestWord()
        {
            Sentence sentence = new Sentence();

            ShortestWord result = sentence.FindShortestWord("The cow jumped joyfully over me");

            Assert.Equal("me", result.Word);
        }
        public void ReturnShortestWordLength()
        {
            Sentence sentence = new Sentence();

            ShortestWord result = sentence.FindShortestWord("I jumped over the cow");

            Assert.Equal(1, result.Length);
        }
Esempio n. 9
0
        public void ShortestWord_RandomTests()
        {
            var rand  = new Random();
            var names = new[] { "Bitcoin", "LiteCoin", "Ripple", "Dash", "Lisk", "DarkCoin", "Monero", "Ethereum", "Classic", "Mine", "ProofOfWork", "ProofOfStake", "21inc", "Steem", "Dogecoin", "Waves", "Factom", "MadeSafeCoin", "BTC" };

            for (var i = 0; i < 40; i++)
            {
                var s = string.Join(" ", Enumerable.Range(0, rand.Next(1, 20)).Select(a => names[rand.Next(0, names.Length)]));

                var expected = s.Split(' ').Select(w => w.Length).Min();

                Assert.AreEqual(expected, ShortestWord.FindShort(s), "It should work for random inputs too");
            }
        }
Esempio n. 10
0
 public void ShortestWord_BasicTest1()
 {
     Assert.AreEqual(3, ShortestWord.FindShort("bitcoin take over the world maybe who knows perhaps"));
 }
Esempio n. 11
0
 public void ShortestWord_BasicTest5()
 {
     Assert.AreEqual(2, ShortestWord.FindShort("Lets all go on holiday somewhere very cold"));
 }
Esempio n. 12
0
 public void ShortestWord_BasicTest4()
 {
     Assert.AreEqual(1, ShortestWord.FindShort("i want to travel the world writing code one day"));
 }
Esempio n. 13
0
 public void ShortestWord_BasicTest3()
 {
     Assert.AreEqual(3, ShortestWord.FindShort("lets talk about javascript the best language"));
 }
Esempio n. 14
0
 public void ShortestWord_BasicTest2()
 {
     Assert.AreEqual(3, ShortestWord.FindShort("turns out random test cases are easier than writing out basic ones"));
 }
Esempio n. 15
0
 public void ShortestWordTests()
 {
     Assert.AreEqual(3, ShortestWord.FindShort("bitcoin take over the world maybe who knows perhaps"));
     Assert.AreEqual(3, ShortestWord.FindShort("turns out random test cases are easier than writing out basic ones"));
 }
Esempio n. 16
0
 public void Test_ShortestWord(string input, int expectedResult)
 {
     Assert.AreEqual(expectedResult, ShortestWord.Short(input));
 }
Esempio n. 17
0
 public void DoesShowTheShortestWord()
 {
     Assert.AreEqual(5, ShortestWord.Compute("Stomil Legia"));
 }