public void EmailAddressTest() { string sentence = "Further information or details can be sent to [email protected], [email protected] or [email protected]"; IDictionary <string, int> calculatedAnswer = new Dictionary <string, int>(); IWordCounter wc = CreateInstance(); calculatedAnswer = wc.CountWordsInStringSequence(sentence); IDictionary <string, int> correctAnswer = new Dictionary <string, int>(); correctAnswer["further"] = 1; correctAnswer["information"] = 1; correctAnswer["or"] = 2; correctAnswer["details"] = 1; correctAnswer["can"] = 1; correctAnswer["be"] = 1; correctAnswer["sent"] = 1; correctAnswer["to"] = 1; correctAnswer["*****@*****.**"] = 2; correctAnswer["*****@*****.**"] = 1; AssertCorrectness(calculatedAnswer, calculatedAnswer); }
public void NullStringTest() { string sequence = null; IDictionary <string, int> calculatedAnswer = new Dictionary <string, int>(); IWordCounter wc = CreateInstance(); calculatedAnswer = wc.CountWordsInStringSequence(sequence); Assert.IsTrue(calculatedAnswer.Count == 0, "Expected empty"); }
public void OnlyDashesTest() { string sequence = "--------"; IDictionary <string, int> calculatedAnswer = new Dictionary <string, int>(); IWordCounter wc = CreateInstance(); calculatedAnswer = wc.CountWordsInStringSequence(sequence); IDictionary <string, int> correctAnswer = new Dictionary <string, int>(); Assert.AreEqual(0, calculatedAnswer.Count, "Some word found - expected empty"); }
public void OneWordWithSpecialCharAtTheEndWithSpaceBetween() { string sequence = "Die !"; IDictionary <string, int> calculatedAnswer = new Dictionary <string, int>(); IWordCounter wc = CreateInstance(); calculatedAnswer = wc.CountWordsInStringSequence(sequence); IDictionary <string, int> correctAnswer = new Dictionary <string, int>(); correctAnswer["die"] = 1; AssertCorrectness(calculatedAnswer, correctAnswer); }
public void OneWordSequenceTest() { string sequence = "Die"; IDictionary <string, int> calculatedAnswer = new Dictionary <string, int>(); IWordCounter wc = CreateInstance(); calculatedAnswer = wc.CountWordsInStringSequence(sequence); IDictionary <string, int> correctAnswer = new Dictionary <string, int>(); correctAnswer["die"] = 1; AssertCorrectness(calculatedAnswer, correctAnswer); }
public void StrangeFrechWordTest() { string sentence = "Qu'est-ce que ?"; IDictionary <string, int> calculatedAnswer = new Dictionary <string, int>(); IWordCounter wc = CreateInstance(); calculatedAnswer = wc.CountWordsInStringSequence(sentence); IDictionary <string, int> correctAnswer = new Dictionary <string, int>(); correctAnswer["qu'est-ce"] = 1; correctAnswer["que"] = 1; AssertCorrectness(calculatedAnswer, correctAnswer); }
public void MultipleSentencesTest() { string sentence = "abc, abc - dbe. Dbe and ref. Abc."; IDictionary <string, int> calculatedAnswer = new Dictionary <string, int>(); IWordCounter wc = CreateInstance(); calculatedAnswer = wc.CountWordsInStringSequence(sentence); IDictionary <string, int> correctAnswer = new Dictionary <string, int>(); correctAnswer["abc"] = 3; correctAnswer["dbe"] = 2; correctAnswer["and"] = 1; correctAnswer["ref"] = 1; AssertCorrectness(calculatedAnswer, correctAnswer); }
public void MultipleWordBreakersWitBeginWithSpaceTests() { string sentence = "abc aftertriplespace afterdoubletab. aftertriplespace and afterdoubletab"; IDictionary <string, int> calculatedAnswer = new Dictionary <string, int>(); IWordCounter wc = CreateInstance(); calculatedAnswer = wc.CountWordsInStringSequence(sentence); IDictionary <string, int> correctAnswer = new Dictionary <string, int>(); correctAnswer["abc"] = 1; correctAnswer["aftertriplespace"] = 2; correctAnswer["afterdoubletab"] = 2; correctAnswer["and"] = 1; AssertCorrectness(calculatedAnswer, correctAnswer); }
public void MultiLineHandlingTest() { string sequence = @"Some Multiline sequence in test."; IDictionary <string, int> calculatedAnswer = new Dictionary <string, int>(); IWordCounter wc = CreateInstance(); calculatedAnswer = wc.CountWordsInStringSequence(sequence); IDictionary <string, int> correctAnswer = new Dictionary <string, int>(); correctAnswer["some"] = 1; correctAnswer["multiline"] = 1; correctAnswer["sequence"] = 1; correctAnswer["in"] = 1; correctAnswer["test"] = 1; AssertCorrectness(calculatedAnswer, correctAnswer); }
public void WordWithDashTest() { string sentence = "This is cross-section of the public."; IDictionary <string, int> calculatedAnswer = new Dictionary <string, int>(); IWordCounter wc = CreateInstance(); calculatedAnswer = wc.CountWordsInStringSequence(sentence); IDictionary <string, int> correctAnswer = new Dictionary <string, int>(); correctAnswer["this"] = 1; correctAnswer["is"] = 1; correctAnswer["cross-section"] = 1; correctAnswer["of"] = 1; correctAnswer["the"] = 1; correctAnswer["public"] = 1; AssertCorrectness(calculatedAnswer, calculatedAnswer); }
public void ExcerciseExampleTest() { string sentence = "This is a statement, and so is this."; IDictionary <string, int> calculatedAnswer = new Dictionary <string, int>(); IWordCounter wc = CreateInstance(); calculatedAnswer = wc.CountWordsInStringSequence(sentence); IDictionary <string, int> correctAnswer = new Dictionary <string, int>(); correctAnswer["this"] = 2; correctAnswer["is"] = 2; correctAnswer["a"] = 1; correctAnswer["statement"] = 1; correctAnswer["and"] = 1; correctAnswer["so"] = 1; AssertCorrectness(calculatedAnswer, calculatedAnswer); }
public void FrenchInterpunctionTest() { string sentence = " Les enfants les règles d'orthographe à l'école primaire. Qu'est-ce que ?"; IDictionary <string, int> calculatedAnswer = new Dictionary <string, int>(); IWordCounter wc = CreateInstance(); calculatedAnswer = wc.CountWordsInStringSequence(sentence); IDictionary <string, int> correctAnswer = new Dictionary <string, int>(); correctAnswer["les"] = 2; correctAnswer["enfants"] = 1; correctAnswer["règles"] = 1; correctAnswer["d'orthographe"] = 1; correctAnswer["à"] = 1; correctAnswer["l'école"] = 1; correctAnswer["primaire"] = 1; correctAnswer["qu'est-ce"] = 1; correctAnswer["que"] = 1; AssertCorrectness(calculatedAnswer, correctAnswer); }
public void MultiLineDialogTest() { string sequence = @"Dialog (me and you): - hi, -Hi you too! -bye"; IDictionary <string, int> calculatedAnswer = new Dictionary <string, int>(); IWordCounter wc = CreateInstance(); calculatedAnswer = wc.CountWordsInStringSequence(sequence); IDictionary <string, int> correctAnswer = new Dictionary <string, int>(); correctAnswer["dialog"] = 1; correctAnswer["me"] = 1; correctAnswer["and"] = 1; correctAnswer["you"] = 2; correctAnswer["hi"] = 2; correctAnswer["too"] = 1; correctAnswer["bye"] = 1; AssertCorrectness(calculatedAnswer, correctAnswer); }