예제 #1
0
 protected override async void OnWindowCreated(WindowCreatedEventArgs args)
 {
     base.OnWindowCreated(args);
     CustomDicManage.DumpWordsFromFileDataBaseToTheDiconaryForTest();
     WordBook.InitDictionaries();
     await WordBook.InitDicCollectionAsync();
 }
예제 #2
0
        private void _viewModel_DialogActions(object sender, CommandArgs args)
        {
            if (args.parameter.Equals("YES"))
            {
                switch (_lastCommand)
                {
                case "NewDic":
                    CustomDicManage.AddACustomDictionary(_viewModel.NewName);
                    break;

                case "ReName":
                    CustomDicManage.ChangeDictionaryName(_viewModel.OpenedDic.Name, _viewModel.NewName);
                    break;

                case "ReMove":
                    WordBook.Custom.Remove(WordBook.Custom[_viewModel.OpenedDic.DBName - 10]);
                    CustomDicManage.DeleteDictionary(_viewModel.OpenedDic.Name);
                    if (WordBook.SelectedDic == _viewModel.OpenedDic.DBName)
                    {
                        WordBook.CustomeDicCounts--;
                        WordBook.SelectedDic = WordBook.CustomeDicCounts > 10 ? WordBook.CustomeDicCounts : 5;
                    }
                    _viewModel.UpdateDicinfo();
                    VisualStateManager.GoToState(this, "BrifeInfo", true);
                    break;

                default: break;
                }
            }
            _lastCommand = null;
            NewDialog.Hide();
            MessageDialog.Hide();
        }
 public void ChangeDictionaryNameTest()
 {
     Assert.AreEqual(true,
                     CustomDicManage.AddACustomDictionary("testDic"));
     Assert.AreEqual(true,
                     CustomDicManage.ChangeDictionaryName("testDic", "testDicChanged"));
 }
        public void GetAllDictionariesNameTest()
        {
            CustomDicManage.AddACustomDictionary("GetAllDictionaryNameTest");
            var re = CustomDicManage.GetAllCustomDictionariesName();

            Assert.AreEqual(1, re.Count());
        }
        public void ChangeTheStateOfAWordTest()
        {
            var v = new Vocabulary
            {
                Word        = "changeStateTest",
                Translation = "改变状态位测试",
                YesorNo     = 0
            };

            CustomDicManage.AddACustomDictionary("changeStateTest");
            Assert.AreEqual(1, CustomDicManage.InsertAVocabularyToCustomDictionary("changeStateTest", v));
            using (var db = new DataContext())
            {
                db.Database.Migrate();
                var test = db.Words.First(vo => vo.Id.Equals(v.Word));
                Assert.AreEqual(0, test.YesorNo);
                db.Database.CloseConnection();
            }

            CustomDicManage.ChangeTheStateOfAWord(v.Word, 1);

            using (var db = new DataContext())
            {
                db.Database.Migrate();
                var test = db.Words.First(vo => vo.Id.Equals(v.Word));
                Assert.AreEqual(1, test.YesorNo);
                db.Database.CloseConnection();
            }
        }
 public void DumpWordsFromWordBookToCustomDictionaryTest()
 {
     fileDatabaseManage.instance = new fileDatabaseManage();
     WordBook.InitDictionaries();
     //fileDatabaseManage.instance.GetDictionaries();
     CustomDicManage.AddACustomDictionary("dumpWordsTest");
     CustomDicManage.DumpWordsFromWordBookToCustomDictionary("dumpWordsTest", WordBook.CET6.Wordlist);
 }
        public void InsertAVocabularyToCustomDictionaryTest()
        {
            // CustomDicManage.AddACustomDictionary("InsertTestDic");
            //Assert.AreEqual(0, CustomDicManage.InsertAVocabularyToCustomDictionary("InsertTestDic",
            //  new Vocabulary
            //  {
            //      Word = "01Test", Translation = "单词关联词典插入测试"
            //  }));

            Assert.AreEqual(1, CustomDicManage.InsertAVocabularyToCustomDictionary("InsertTestDic",
                                                                                   new Vocabulary
            {
                Word        = "test",
                Translation = "测试"
            }));
        }
 public void DeleteDictionaryTest()
 {
     CustomDicManage.AddACustomDictionary("DeleteTestDic");
     Assert.AreEqual(1, CustomDicManage.InsertAVocabularyToCustomDictionary("DeleteTestDic",
                                                                            new ExReaderPlus.WordsManager.Vocabulary
     {
         Word        = "001Test",
         Translation = "单词关联词典插入测试"
     }));
     Assert.AreEqual(1, CustomDicManage.InsertAVocabularyToCustomDictionary("DeleteTestDic",
                                                                            new ExReaderPlus.WordsManager.Vocabulary
     {
         Word        = "002Test",
         Translation = "单词关联词典插入测试"
     }));
     Assert.AreEqual(1, CustomDicManage.InsertAVocabularyToCustomDictionary("DeleteTestDic",
                                                                            new ExReaderPlus.WordsManager.Vocabulary
     {
         Word        = "003Test",
         Translation = "单词关联词典插入测试"
     }));
     Assert.AreEqual(1, CustomDicManage.DeleteDictionary("DeleteTestDic"));
 }
 public void DumpWordsFromFileDataBaseToTheDiconaryForTestTest()
 {
     Assert.AreEqual(1, CustomDicManage.DumpWordsFromFileDataBaseToTheDiconaryForTest());
 }