예제 #1
0
 public override bool RemoveDictionary(DictionaryInfo dictionary)
 {
     if (dictionary == null)
         return false;
     File.Delete(GetFullPath(dictionary.Name));
     return Dictionaries.Remove(dictionary);
 }
예제 #2
0
        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;
        }
예제 #3
0
 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"));
     }
 }
예제 #4
0
 public abstract bool RemoveDictionary(DictionaryInfo dictionary);
예제 #5
0
 public void TestDictionaryInfoEqual2()
 {
     info = new DictionaryInfo(name, dataLayer);
     DictionaryInfo newInfo = new DictionaryInfo(String.Copy(name), dataLayer);
     Assert.AreEqual(newInfo, info);
 }
예제 #6
0
 public void TestDictionaryInfoEqual1()
 {
     info = new DictionaryInfo(name, dataLayer);
     Assert.AreEqual(info, info);
 }
예제 #7
0
 public void TestDictionaryInfoNotEqual2()
 {
     info = new DictionaryInfo(name, dataLayer);
     Assert.AreNotEqual(null, info);
 }
예제 #8
0
 public void TestDictionaryInfoNotEqual1()
 {
     info = new DictionaryInfo(name, dataLayer);
     DictionaryInfo newInfo = new DictionaryInfo(name + "123", dataLayer);
     Assert.AreNotEqual(newInfo, info);
 }