public void TestAddition_ValidWord() { MyWordDictionary dict = new MyWordDictionary(); Assert.IsTrue(dict.AddWord("a"), "Error adding 'a'"); Assert.IsTrue(dict.AddWord("an"), "Error adding 'an'"); Assert.IsTrue(dict.AddWord("and"), "Error adding 'and'"); //TestAddition_MixCase Assert.IsTrue(dict.AddWord("hELlo"), "Error adding mixed case string 'hELlo'"); }
public void TestAddition_InvalidChar() { MyWordDictionary dict = new MyWordDictionary(); Assert.IsFalse(dict.AddWord("a,b"), "Should not allow ','"); Assert.IsFalse(dict.AddWord(":SDf:"), "Should not allow ':'"); Assert.IsFalse(dict.AddWord("and&"), "Should not allow '&'"); //TestAddition_BlankOrNull Assert.IsFalse(dict.AddWord(""), "Should not allow blank"); Assert.IsFalse(dict.AddWord(" "), "Should not allow blank"); Assert.IsFalse(dict.AddWord(null), "Should not allow blank"); }
public void TestIsValid_passValid() { MyWordDictionary dict = new MyWordDictionary(); dict.AddWord("a"); dict.AddWord("an"); dict.AddWord("am"); dict.AddWord("and"); dict.AddWord("hELlo"); Assert.IsTrue(dict.AddWord("an"), "Error finding 'an'"); Assert.IsTrue(dict.IsValidWord("and"), "Error finding 'and'"); Assert.IsTrue(dict.IsValidWord("Hello"), "Error finding 'Hello'"); //TestIsValid_passNonExistingWord Assert.IsFalse(dict.IsValidWord("Amd"), "'Amd' is not existing"); Assert.IsFalse(dict.IsValidWord("A&d"), "'&' is invalid char"); }
public void Test_AreAllWordsValid() { MyWordDictionary d = new MyWordDictionary(); d.AddWord("be"); d.AddWord("beg"); d.AddWord("begun"); d.AddWord("cod"); d.AddWord("code"); d.AddWord("coding"); d.AddWord("encode"); d.AddWord("decode"); d.AddWord("new"); d.AddWord("news"); d.AddWord("old"); d.AddWord("gold"); d.AddWord("eco"); d.AddWord("dog"); d.AddWord("cat"); d.AddWord("fish"); Assert.IsTrue(Strings.AreAllValidWords("beguncode", d), "Its true. Valid words should be 'begun', 'code'"); Assert.IsTrue(Strings.AreAllValidWords("dogcatfish", d), "Its true. dog, cat, fish"); Assert.IsFalse(Strings.AreAllValidWords("beguencode", d), "Its false. 'begu', 'encode'"); Assert.IsFalse(Strings.AreAllValidWords("begunecode", d), "Its false. 'ecode'"); }