示例#1
0
        public void WordsFromString_ValidStringLine_ReturnsCorrectWordList()
        {
            string line = "This is my test file which contains some text." +
                          "this checks if it's a word or a number(1234) or just punctuation('\"\\/!?-)." +
                          "Seventy-five is one word. don't is one." +
                          "\"Emmerich\", \"Emmerich's\", \"Emmerichs\" are different.";

            List <string> expectedWords = new List <string>()
            {
                "This", "is", "my", "test", "file", "which", "contains", "some", "text",
                "this", "checks", "if", "it's", "a", "word", "or", "a", "number", "or", "just", "punctuation",
                "Seventy-five", "is", "one", "word", "don't", "is", "one",
                "Emmerich", "Emmerich's", "Emmerichs", "are", "different"
            };

            List <string> actualWords = FileWordCounter.WordsFromString(line).ToList();

            Assert.AreEqual(expectedWords, actualWords);
        }
示例#2
0
 public void CountWords_InvalidFilePath_ThrowFileNotFoundException()
 {
     Assert.Throws <FileNotFoundException>(new TestDelegate(() => FileWordCounter.CountWords("", StringComparer.CurrentCultureIgnoreCase)));
 }
示例#3
0
 public void CountWords_ValidFilePath_ReturnsCorrectWordCount()
 {
     Assert.AreEqual(_testFileWordCounts, FileWordCounter.CountWords(_testFilePath, StringComparer.CurrentCultureIgnoreCase));
 }
示例#4
0
 public void WordsFromString_StringWithNoValidWords_ReturnsEmptyWordList()
 {
     Assert.AreEqual(new List <string>(), FileWordCounter.WordsFromString("123456 --- !'\\\"/?><"));
 }
示例#5
0
 public void WordsFromString_EmptyString_ReturnsEmptyWordList()
 {
     Assert.AreEqual(new List <string>(), FileWordCounter.WordsFromString(string.Empty));
 }
示例#6
0
 public void WordsFromString_Null_ThrowArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => FileWordCounter.WordsFromString(null));
 }