public void TestXmlDictionariesServiceAddToNewFolder()
 {
     dictionaryService = new XmlDictionariesService(folder);
     bool result = dictionaryService.AddDictionary("test", "Lang1", "Lang2");
     Assert.IsTrue(result);
     Assert.AreEqual(1, dictionaryService.Dictionaries.Count);
 }
 public void TestXmlDictionariesServiceInit1Dictionary()
 {
     string dName = "test";
     dataLayer = new XmlDataLayer(Path.Combine(folder, dName + ".xml"));
     dataLayer.Save(dictionary);
     dictionaryService = new XmlDictionariesService(folder);
     Assert.AreEqual(1, dictionaryService.Dictionaries.Count);
 }
        public DictionariesControl()
        {
            InitializeComponent();

            string folder = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "WordsTraining");
            dictionariesService = new XmlDictionariesService(folder);
            DictionariesList = dictionariesService.Dictionaries;
            DataContext = this;
        }
 public void TestXmlDictionariesServiceAddOk()
 {
     string dName1 = "test1";
     dataLayer = new XmlDataLayer(Path.Combine(folder, dName1 + ".xml"));
     dataLayer.Save(dictionary);
     string dName2 = "test2";
     dataLayer = new XmlDataLayer(Path.Combine(folder, dName2 + ".xml"));
     dataLayer.Save(dictionary);
     dictionaryService = new XmlDictionariesService(folder);
     Assert.AreEqual(2, dictionaryService.Dictionaries.Count);
     bool result = dictionaryService.AddDictionary("test", "Lang1", "Lang2");
     Assert.IsTrue(result);
     Assert.AreEqual(3, dictionaryService.Dictionaries.Count);
 }
 public void TestXmlDictionariesServiceRemoveByName()
 {
     string dName = "test";
     dataLayer = new XmlDataLayer(Path.Combine(folder, dName + ".xml"));
     dataLayer.Save(dictionary);
     dictionaryService = new XmlDictionariesService(folder);
     bool result = dictionaryService.RemoveDictionary(dName);
     Assert.IsTrue(result);
     Assert.AreEqual(0, dictionaryService.Dictionaries.Count);
 }
        public void TestXmlDictionariesServiceAddDuplicate()
        {
            string dName1 = "test1";
            dictionaryService = new XmlDictionariesService(folder);
            dictionaryService.AddDictionary(dName1, "Lang1", "Lang2");
            bool result = dictionaryService.AddDictionary(dName1, "WrongLang1", "WrongLang2");
            Assert.IsFalse(result);
            Assert.AreEqual(1, dictionaryService.Dictionaries.Count);

            // check that old dictionary was not overwritten
            dictionaryService = new XmlDictionariesService(folder);
            Assert.AreEqual("Lang1", dictionaryService.Dictionaries[0].Language1);
        }
 public void TestXmlDictionariesServiceInitFailed()
 {
     string dName = "test";
     File.WriteAllText(Path.Combine(folder, dName + ".xml"), "Fake");
     dictionaryService = new XmlDictionariesService(folder);
 }
 public void TestXmlDictionariesServiceInitWithEmptyFolder()
 {
     dictionaryService = new XmlDictionariesService(folder);
     Assert.AreEqual(0, dictionaryService.Dictionaries.Count, "Validating that dictionaries were not created after read empty folder ");
 }
 public void TestXmlDictionariesServiceAddRemove()
 {
     string dName = "test";            
     dictionaryService = new XmlDictionariesService(folder);
     dictionaryService.AddDictionary(dName, "Lang1", "Lang2");
     bool result = dictionaryService.RemoveDictionary(dName);
     Assert.IsTrue(result);
     Assert.AreEqual(0, dictionaryService.Dictionaries.Count);
 }
 public void TestXmlDictionariesServiceRemoveByNameEmpty()
 {
     dictionaryService = new XmlDictionariesService(folder);
     bool result = dictionaryService.RemoveDictionary("test");
     Assert.IsFalse(result);
     Assert.AreEqual(0, dictionaryService.Dictionaries.Count);
 }