public override bool RemoveDictionary(DictionaryInfo dictionary) { if (dictionary == null) return false; File.Delete(GetFullPath(dictionary.Name)); return Dictionaries.Remove(dictionary); }
public override bool AddDictionary(string name, string lang1, string lang2) { DictionaryInfo check = GetDictionary(name); if (check != null) return false; WordsDictionary dictionary = new WordsDictionary(lang1, lang2); dictionary.Add(new WordCard("Hello", "Hello", WordType.Noun)); // HACK: DataLayer data = new XmlDataLayer(GetFullPath(name)); data.Save(dictionary); DictionaryInfo dictionaryInfo = new DictionaryInfo(name, data); Dictionaries.Add(dictionaryInfo); return true; }
public void TestDictionaryInfoInit() { info = new DictionaryInfo(name, dataLayer); Assert.AreEqual(name, info.Name, "Validating name"); Assert.AreEqual(language1, info.Language1, "Validating lang1"); Assert.AreEqual(language2, info.Language2, "Validating lang2"); Assert.AreEqual(dictionary.Count, info.NumOfCards, "Validating number of cards"); foreach (var type in WordCard.TrainingTypes) { double average = 0; foreach (var card in dictionary) { average += (card.Counter1[type] + card.Counter2[type]) / 2.0; } average /= dictionary.Count; Assert.AreEqual(average.ToString("0.00"), info.TrainingAverage[type].ToString("0.00")); } }
public abstract bool RemoveDictionary(DictionaryInfo dictionary);
public void TestDictionaryInfoEqual2() { info = new DictionaryInfo(name, dataLayer); DictionaryInfo newInfo = new DictionaryInfo(String.Copy(name), dataLayer); Assert.AreEqual(newInfo, info); }
public void TestDictionaryInfoEqual1() { info = new DictionaryInfo(name, dataLayer); Assert.AreEqual(info, info); }
public void TestDictionaryInfoNotEqual2() { info = new DictionaryInfo(name, dataLayer); Assert.AreNotEqual(null, info); }
public void TestDictionaryInfoNotEqual1() { info = new DictionaryInfo(name, dataLayer); DictionaryInfo newInfo = new DictionaryInfo(name + "123", dataLayer); Assert.AreNotEqual(newInfo, info); }