public void Test_GetWordsInCategory1() { string category = "CSharp"; string filename = "LingoWords.xml"; string cwd = Directory.GetCurrentDirectory(); string fullFilePath = Path.Combine(cwd, filename); XElement xElements = null; List <string> words = FileManagementHelper.GetWordsInCategory(category); using (StreamReader reader = File.OpenText(fullFilePath)) { xElements = XElement.Load(reader); } IEnumerable <XElement> itemsXml = xElements.Descendants("Item"); List <string> baseWords = new List <string>(); foreach (XElement item in itemsXml) { if (item.Element("Category").Value == "CSharp") { baseWords.Add(item.Element("Word").Value); } } var firstNotSecond = words.Except(baseWords).ToList(); var secondNotFirst = baseWords.Except(words).ToList(); Assert.IsTrue(firstNotSecond.Count == 0 && secondNotFirst.Count == 0); }
public void Test_GetWordsInCategory() { List <string> words = FileManagementHelper.GetWordsInCategory("CSharp"); string keyWord = "method"; bool expectedResult = true; bool actualResult = words.Contains(keyWord); Assert.AreEqual(expectedResult, actualResult); }
public void Test_GetWordsInCategory_InvalidIsZero() { List <string> words = null; words = FileManagementHelper.GetWordsInCategory("alskdh"); int expectedResult = 0; int actualResult = words.Count; Assert.AreEqual(expectedResult, actualResult); }