public void FwNewLangProjectModel_CannotClickFinishWithBlankProjectName() { var model = new FwNewLangProjectModel(); model.LoadProjectNameSetup = () => { }; model.LoadVernacularSetup = () => { }; model.LoadAnalysisSetup = () => { }; model.LoadAdvancedWsSetup = () => { }; model.LoadAnthropologySetup = () => { }; model.ProjectName = DbName; var fakeTestWs = new CoreWritingSystemDefinition("fr"); model.WritingSystemContainer.CurrentVernacularWritingSystems.Add(fakeTestWs); model.WritingSystemContainer.VernacularWritingSystems.Add(fakeTestWs); model.WritingSystemContainer.CurrentAnalysisWritingSystems.Add(fakeTestWs); model.WritingSystemContainer.AnalysisWritingSystems.Add(fakeTestWs); Assert.True(model.CanGoNext()); model.Next(); // Vernacular model.Next(); // Analysis Assert.True(model.CanFinish()); model.Back(); model.Back(); model.ProjectName = ""; Assert.False(model.CanFinish()); }
public void SetDefaultWs_Analysis() { var model = new FwNewLangProjectModel(true) { LoadProjectNameSetup = () => { }, LoadVernacularSetup = () => { }, LoadAnalysisSetup = () => { }, ProjectName = DbName }; model.Next(); model.WritingSystemContainer.AddToCurrentVernacularWritingSystems(new CoreWritingSystemDefinition("fr")); model.Next(); // English is the default Analysis WS, so we do not need to set it here. Assert.That(model.WritingSystemContainer.AnalysisWritingSystems.Count, Is.EqualTo(1), "Test setup problem"); Assert.That(model.WritingSystemContainer.AnalysisWritingSystems.First().LanguageTag, Is.EqualTo("en"), "Test setup problem"); Assert.That(model.WritingSystemContainer.CurrentAnalysisWritingSystems.Count, Is.EqualTo(1), "Test setup problem"); Assert.That(model.WritingSystemContainer.CurrentAnalysisWritingSystems.First().LanguageTag, Is.EqualTo("en"), "Test setup problem"); model.SetDefaultWs(new LanguageInfo { LanguageTag = "de" }); Assert.That(model.WritingSystemContainer.AnalysisWritingSystems.Count, Is.EqualTo(1), "all"); Assert.That(model.WritingSystemContainer.AnalysisWritingSystems.First().LanguageTag, Is.EqualTo("de"), "should be German"); Assert.That(model.WritingSystemContainer.CurrentAnalysisWritingSystems.Count, Is.EqualTo(1), "current"); Assert.That(model.WritingSystemContainer.CurrentAnalysisWritingSystems[0].LanguageTag, Is.EqualTo("de"), "default should be German"); }
public void FwNewLangProjectModel_VernacularAndAnalysisSame_WarningIssued() { bool warningIssued = false; var model = new FwNewLangProjectModel(); model.LoadProjectNameSetup = () => { }; model.LoadVernacularSetup = () => { }; model.LoadAnalysisSetup = () => { }; model.LoadAnalysisSameAsVernacularWarning = () => { warningIssued = true; }; model.ProjectName = DbName; var fakeTestWs = new CoreWritingSystemDefinition("fr"); model.WritingSystemContainer.CurrentVernacularWritingSystems.Add(fakeTestWs); model.WritingSystemContainer.VernacularWritingSystems.Add(fakeTestWs); model.WritingSystemContainer.CurrentAnalysisWritingSystems.Add(fakeTestWs); model.WritingSystemContainer.AnalysisWritingSystems.Add(fakeTestWs); Assert.True(model.CanGoNext()); model.Next(); // Move to choose default vernacular Assert.True(model.CanGoNext()); model.Next(); // Move to choose default analysis model.SetDefaultWs(new LanguageInfo() { LanguageTag = "fr" }); Assert.True(warningIssued, "Warning for analysis same as vernacular not triggered"); Assert.True(model.CanGoNext()); // The user can ignore the warning }
public void SetDefaultWs_PreservesCheckState() { var model = new FwNewLangProjectModel(true) { LoadProjectNameSetup = () => { }, LoadVernacularSetup = () => { }, ProjectName = DbName }; model.Next(); var french = new CoreWritingSystemDefinition("fr"); var esperanto = new CoreWritingSystemDefinition("eo"); var english = new CoreWritingSystemDefinition("en"); model.WritingSystemContainer.AddToCurrentVernacularWritingSystems(french); // selected model.WritingSystemContainer.AddToCurrentVernacularWritingSystems(esperanto); // selected model.WritingSystemContainer.VernacularWritingSystems.Add(english); // deselected model.SetDefaultWs(new LanguageInfo { LanguageTag = "de" }); Assert.That(model.WritingSystemContainer.VernacularWritingSystems.Count, Is.EqualTo(3), "should be three total"); Assert.That(model.WritingSystemContainer.VernacularWritingSystems.First().LanguageTag, Is.EqualTo("de"), "first should be German"); Assert.That(model.WritingSystemContainer.VernacularWritingSystems.Contains(esperanto), "should contain Esperanto"); Assert.That(model.WritingSystemContainer.VernacularWritingSystems.Contains(english), "should contain English"); Assert.That(model.WritingSystemContainer.CurrentVernacularWritingSystems.Count, Is.EqualTo(2), "should be two selected"); Assert.That(model.WritingSystemContainer.CurrentVernacularWritingSystems[0].LanguageTag, Is.EqualTo("de"), "default should be German"); Assert.Contains(esperanto, (ICollection)model.WritingSystemContainer.CurrentVernacularWritingSystems, "Esperanto should be selected"); }
public void FwNewLangProjectModel_CanGoBack() { var model = new FwNewLangProjectModel(); model.LoadProjectNameSetup = () => { }; model.LoadVernacularSetup = () => { }; model.ProjectName = DbName; Assert.False(model.CanGoBack()); model.Next(); Assert.True(model.CanGoBack()); model.Back(); Assert.False(model.CanGoBack()); }
private static void CreateDb(string dbName, string vernWs = "fr") { var testProject = new FwNewLangProjectModel(true) { LoadProjectNameSetup = () => { }, LoadVernacularSetup = () => { }, LoadAnalysisSetup = () => { }, ProjectName = dbName, AnthroModel = new FwChooseAnthroListModel { CurrentList = FwChooseAnthroListModel.ListChoice.UserDef } }; testProject.Next(); testProject.SetDefaultWs(new LanguageInfo { LanguageTag = vernWs }); testProject.Next(); using (var threadHelper = new ThreadHelper()) { testProject.CreateNewLangProj(new DummyProgressDlg(), threadHelper); } }
public void SetDefaultWs_DoesNotDuplicate() { var model = new FwNewLangProjectModel(true) { LoadProjectNameSetup = () => { }, LoadVernacularSetup = () => { }, ProjectName = DbName }; model.Next(); model.WritingSystemContainer.AddToCurrentVernacularWritingSystems(new CoreWritingSystemDefinition("de")); model.SetDefaultWs(new LanguageInfo { LanguageTag = "de" }); Assert.That(model.WritingSystemContainer.VernacularWritingSystems.Count, Is.EqualTo(1), "should be only one WS"); Assert.That(model.WritingSystemContainer.VernacularWritingSystems.First().LanguageTag, Is.EqualTo("de"), "should be German"); Assert.That(model.WritingSystemContainer.CurrentVernacularWritingSystems.Count, Is.EqualTo(1), "should be only one current"); Assert.That(model.WritingSystemContainer.CurrentVernacularWritingSystems.First().LanguageTag, Is.EqualTo("de"), "default should be German"); }
public void SetDefaultWs_ReplacesExistingDefault() { var model = new FwNewLangProjectModel(true) { LoadProjectNameSetup = () => { }, LoadVernacularSetup = () => { }, ProjectName = DbName }; model.Next(); model.WritingSystemContainer.AddToCurrentVernacularWritingSystems(new CoreWritingSystemDefinition("fr")); model.WritingSystemContainer.AddToCurrentVernacularWritingSystems(new CoreWritingSystemDefinition("en")); model.SetDefaultWs(new LanguageInfo { LanguageTag = "de" }); Assert.That(model.WritingSystemContainer.VernacularWritingSystems.Count, Is.EqualTo(2), "all"); Assert.That(model.WritingSystemContainer.VernacularWritingSystems.First().LanguageTag, Is.EqualTo("de"), "first should be German"); Assert.That(model.WritingSystemContainer.CurrentVernacularWritingSystems.Count, Is.EqualTo(2), "current"); Assert.That(model.WritingSystemContainer.CurrentVernacularWritingSystems.First().LanguageTag, Is.EqualTo("de"), "default should be German"); }
public void SetDefaultWs_ManyExist_OthersArePreservedInOrder() { var model = new FwNewLangProjectModel(true) { LoadProjectNameSetup = () => { }, LoadVernacularSetup = () => { }, ProjectName = DbName }; model.Next(); model.WritingSystemContainer.AddToCurrentVernacularWritingSystems(new CoreWritingSystemDefinition("en")); model.WritingSystemContainer.AddToCurrentVernacularWritingSystems(new CoreWritingSystemDefinition("de")); model.WritingSystemContainer.AddToCurrentVernacularWritingSystems(new CoreWritingSystemDefinition("fr")); model.SetDefaultWs(new LanguageInfo { LanguageTag = "de" }); Assert.That(model.WritingSystemContainer.VernacularWritingSystems.Count, Is.EqualTo(3), "all"); Assert.That(model.WritingSystemContainer.VernacularWritingSystems.First().LanguageTag, Is.EqualTo("de"), "first should be German"); Assert.That(model.WritingSystemContainer.CurrentVernacularWritingSystems.Count, Is.EqualTo(3), "current"); Assert.That(model.WritingSystemContainer.CurrentVernacularWritingSystems[0].LanguageTag, Is.EqualTo("de"), "default should be German"); Assert.That(model.WritingSystemContainer.CurrentVernacularWritingSystems[1].LanguageTag, Is.EqualTo("en"), "econd should be English"); Assert.That(model.WritingSystemContainer.CurrentVernacularWritingSystems[2].LanguageTag, Is.EqualTo("fr"), "third should be French"); }
private void OnNextClick(object sender, EventArgs e) { m_model.Next(); }
public void FwNewLangProjectModel_VerifyCreateNewLangProject() { LcmCache cache = null; var testProject = new FwNewLangProjectModel(true) { LoadProjectNameSetup = () => { }, LoadVernacularSetup = () => { }, LoadAnalysisSetup = () => { }, AnthroModel = new FwChooseAnthroListModel { CurrentList = FwChooseAnthroListModel.ListChoice.UserDef } }; try { testProject.ProjectName = DbName; testProject.Next(); testProject.SetDefaultWs(new LanguageInfo { LanguageTag = "fr" }); testProject.Next(); testProject.SetDefaultWs(new LanguageInfo { LanguageTag = "de" }); using (var threadHelper = new ThreadHelper()) { testProject.CreateNewLangProj(new DummyProgressDlg(), threadHelper); } Assert.IsTrue(DbExists(DbName)); // despite of the name is DummyProgressDlg no real dialog (doesn't derive from Control), so // we don't need a 'using' cache = LcmCache.CreateCacheFromExistingData( new TestProjectId(BackendProviderType.kXMLWithMemoryOnlyWsMgr, DbFilename(DbName)), "en", new DummyLcmUI(), FwDirectoryFinder.LcmDirectories, new LcmSettings(), new DummyProgressDlg()); CheckInitialSetOfPartsOfSpeech(cache); Assert.AreEqual(2, cache.ServiceLocator.WritingSystems.AnalysisWritingSystems.Count); Assert.AreEqual("German", cache.ServiceLocator.WritingSystems.AnalysisWritingSystems.First().LanguageName); Assert.AreEqual("English", cache.ServiceLocator.WritingSystems.AnalysisWritingSystems.Last().LanguageName); Assert.AreEqual(2, cache.ServiceLocator.WritingSystems.CurrentAnalysisWritingSystems.Count); Assert.AreEqual("German", cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.LanguageName); Assert.AreEqual("English", cache.ServiceLocator.WritingSystems.CurrentAnalysisWritingSystems.Last().LanguageName, "English should be selected as an analysis writing system even if the user tried to remove it"); Assert.AreEqual(1, cache.ServiceLocator.WritingSystems.VernacularWritingSystems.Count); Assert.AreEqual("French", cache.ServiceLocator.WritingSystems.VernacularWritingSystems.First().LanguageName); Assert.AreEqual(1, cache.ServiceLocator.WritingSystems.CurrentVernacularWritingSystems.Count); Assert.AreEqual("French", cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem.LanguageName); } finally { // Blow away the database to clean things up if (cache != null) { cache.Dispose(); } DestroyDb(DbName, false); } }