public void NumMatches_WordListIsNull() { // Arrange WordListXml xmlWords = null; WordListRazor viewWords = new WordListRazor("TEST LABEL UNIT", ' '); // Act int numMatches = this.NumMatches(xmlWords, viewWords); // Assert // There need be no assertions since a NullReferenceException is the only expected result }
public static Models.WordList ConvertToObject(WordListXml wordListXml) { var words = new List <Word>(); foreach (WordXml wordXml in wordListXml.Words) { words.Add(ConvertToObject(wordXml)); } var wordList = new Models.WordList(); wordList.Populate(words); return(wordList); }
public static WordListXml ConvertToXml(Models.WordList wordList) { var wordListXml = new WordListXml(); List <Word> words = wordList.GetAllWords().Select(w => w.Word).ToList(); wordListXml.Words = new WordXml[words.Count]; int idx = 0; foreach (Word word in words) { wordListXml.Words[idx++] = ConvertToXml(word); } return(wordListXml); }
public void NumMatches_WordListIsEmpty() { // Arrange XmlNode testNode = GetXmlNode("NumMatchesTest.xml", "/content-item/labels", "label", "TEST-LABEL-FOR-UNIT-TEST"); WordListXml xmlWords = new WordListXml(testNode, ' '); WordListRazor viewWords = new WordListRazor("TEST LABEL UNIT", ' '); xmlWords.Words.RemoveRange(0, xmlWords.Words.Count); // This is to empty the list for this test Assert.IsTrue(xmlWords.Words.Count == 0, "xmlWords.Words was expected to be empty"); Assert.IsTrue(viewWords.Words.Count == 3, "viewWords.Words was expected to have 3 words"); // Act int numMatches = this.NumMatches(xmlWords, viewWords); // Assert Assert.AreEqual(numMatches, 0, "NumMatches was expected to be zero."); }
public void NumMatches_WordListsHaveValues() { // Arrange string fileName = "NumMatchesTest.xml"; XmlNode testNode = GetXmlNode(fileName, "/content-item/labels", "label", "TEST-LABEL-FOR-UNIT-TEST"); WordListXml xmlWords = new WordListXml(testNode, ' '); WordListRazor viewWords = new WordListRazor("TEST LABEL UNIT", ' '); Assert.IsNotNull(xmlWords, "xmlWords was not expected to be null"); Assert.IsNotNull(viewWords, "viewWords was not expected to be null"); Assert.IsNotNull(xmlWords.Words, "xmlWords.Words was not expected to be null"); Assert.IsNotNull(viewWords.Words, "viewWords.Words was not expected to be null"); Assert.IsTrue(xmlWords.Words.Count == 5, "xmlWords.Words was expected to have 5 words but had " + xmlWords.Words.Count.ToString()); Assert.IsTrue(viewWords.Words.Count == 3, "viewWords.Words was expected to have 3 words but had " + viewWords.Words.Count.ToString()); // Act int numMatches = this.NumMatches(xmlWords, viewWords); // Assert Assert.AreEqual(numMatches, 3, "NumMatches was expected to be three. Check file: " + fileName); }