public void Write_ValidXml_XmlUpdated()
        {
            const string projectSettingsXml =
                @"<ProjectLexiconSettings projectSharing=""false"">
  <WritingSystems addToSldr=""false"">
    <WritingSystem id=""fr-FR"">
      <SpellCheckingId>fr_FR</SpellCheckingId>
      <LegacyMapping>converter</LegacyMapping>
      <Keyboard>Old Keyboard</Keyboard>
    </WritingSystem>
  </WritingSystems>
</ProjectLexiconSettings>";

            var settingsStore = new MemorySettingsStore {
                SettingsElement = XElement.Parse(projectSettingsXml)
            };
            var projectSettingsDataMapper = new ProjectLexiconSettingsDataMapper(settingsStore);
            var settings = new ProjectLexiconSettings {
                AddWritingSystemsToSldr = true, ProjectSharing = true
            };

            projectSettingsDataMapper.Write(settings);

            Assert.That(settingsStore.SettingsElement, Is.XmlEqualTo(
                            @"<ProjectLexiconSettings projectSharing=""true"">
  <WritingSystems addToSldr=""true"">
    <WritingSystem id=""fr-FR"">
      <SpellCheckingId>fr_FR</SpellCheckingId>
      <LegacyMapping>converter</LegacyMapping>
      <Keyboard>Old Keyboard</Keyboard>
    </WritingSystem>
  </WritingSystems>
</ProjectLexiconSettings>"));
        }
        public void ProjectSharing_Is_Unchecked()
        {
            const string projectSettingsXml =
                @"<ProjectLexiconSettings projectSharing=""true"">
  <WritingSystems addToSldr=""false"">
	<WritingSystem id=""fr-FR"">
		<SpellCheckingId>fr_FR</SpellCheckingId>
		<LegacyMapping>converter</LegacyMapping>
		<Keyboard>Old Keyboard</Keyboard>
	</WritingSystem>
</WritingSystems>
</ProjectLexiconSettings>";

            var settingsStore = new MemorySettingsStore {
                SettingsElement = XElement.Parse(projectSettingsXml)
            };
            var projectSettingsDataMapper = new ProjectLexiconSettingsDataMapper(settingsStore);
            var settings = new ProjectLexiconSettings {
                AddWritingSystemsToSldr = true, ProjectSharing = false
            };

            projectSettingsDataMapper.Write(settings);

            Assert.That(settingsStore.SettingsElement, Is.EqualTo(XElement.Parse(
                                                                      @"<ProjectLexiconSettings projectSharing=""false"">
  <WritingSystems addToSldr=""true"">
	<WritingSystem id=""fr-FR"">
		<SpellCheckingId>fr_FR</SpellCheckingId>
		<LegacyMapping>converter</LegacyMapping>
		<Keyboard>Old Keyboard</Keyboard>
	</WritingSystem>
</WritingSystems>
</ProjectLexiconSettings>")).Using((IEqualityComparer <XNode>) new XNodeEqualityComparer()));
        }
Beispiel #3
0
        public void TestThatSharedSettingOpensXmlDataTypeAsSharedXml()
        {
            const string dbName = "ProjectSharingTest";

            SureRemoveDb(dbName);
            var preExistingDirs = new List <string>(Directory.GetDirectories(m_projectsDirectory));

            try
            {
                // create project
                string dbFileName = LcmCache.CreateNewLangProj(new DummyProgressDlg(), dbName, m_lcmDirectories,
                                                               new SingleThreadedSynchronizeInvoke());
                // Set up test file for project sharing setting
                var testFileStore = new FileSettingsStore(LexiconSettingsFileHelper.GetProjectLexiconSettingsPath(Path.GetDirectoryName(dbFileName)));
                var dataMapper    = new ProjectLexiconSettingsDataMapper(testFileStore);
                dataMapper.Write(new ProjectLexiconSettings {
                    ProjectSharing = true
                });
                // SUT
                // Request XML backend with project settings that have ProjectSharing set to true
                var projectId = new TestProjectId(BackendProviderType.kXML, dbFileName);
                using (var cache = LcmCache.CreateCacheFromExistingData(projectId, "en", m_ui, m_lcmDirectories, new LcmSettings(),
                                                                        new DummyProgressDlg()))
                {
                    var dataSetup = cache.ServiceLocator.GetInstance <IDataSetup>();
                    Assert.IsTrue(dataSetup is SharedXMLBackendProvider, "The project should have been opened as shared xml.");
                }
            }
            finally
            {
                RemoveTestDirs(preExistingDirs, Directory.GetDirectories(m_projectsDirectory));
            }
        }
		public void Write_ValidXml_XmlUpdated()
		{
			const string projectSettingsXml =
@"<ProjectLexiconSettings>
  <WritingSystems addToSldr=""false"">
    <WritingSystem id=""fr-FR"">
      <SpellCheckingId>fr_FR</SpellCheckingId>
      <LegacyMapping>converter</LegacyMapping>
      <Keyboard>Old Keyboard</Keyboard>
    </WritingSystem>
  </WritingSystems>
</ProjectLexiconSettings>";

			var settingsStore = new MemorySettingsStore {SettingsElement = XElement.Parse(projectSettingsXml)};
			var projectSettingsDataMapper = new ProjectLexiconSettingsDataMapper(settingsStore);
			var settings = new ProjectLexiconSettings {AddWritingSystemsToSldr = true};
			projectSettingsDataMapper.Write(settings);

			Assert.That(settingsStore.SettingsElement, Is.EqualTo(XElement.Parse(
@"<ProjectLexiconSettings>
  <WritingSystems addToSldr=""true"">
    <WritingSystem id=""fr-FR"">
      <SpellCheckingId>fr_FR</SpellCheckingId>
      <LegacyMapping>converter</LegacyMapping>
      <Keyboard>Old Keyboard</Keyboard>
    </WritingSystem>
  </WritingSystems>
</ProjectLexiconSettings>")).Using((IEqualityComparer<XNode>) new XNodeEqualityComparer()));
		}
		public void Write_EmptyXml_XmlUpdated()
		{
			var settingsStore = new MemorySettingsStore();
			var projectSettingsDataMapper = new ProjectLexiconSettingsDataMapper(settingsStore);

			var settings = new ProjectLexiconSettings {AddWritingSystemsToSldr = true};
			projectSettingsDataMapper.Write(settings);

			Assert.That(settingsStore.SettingsElement, Is.EqualTo(XElement.Parse(
@"<ProjectLexiconSettings>
  <WritingSystems addToSldr=""true"" />
</ProjectLexiconSettings>")).Using((IEqualityComparer<XNode>) new XNodeEqualityComparer()));
		}
        public void Write_EmptyXml_XmlUpdated()
        {
            var settingsStore             = new MemorySettingsStore();
            var projectSettingsDataMapper = new ProjectLexiconSettingsDataMapper(settingsStore);

            var settings = new ProjectLexiconSettings {
                AddWritingSystemsToSldr = true, ProjectSharing = true
            };

            projectSettingsDataMapper.Write(settings);

            Assert.That(settingsStore.SettingsElement, Is.XmlEqualTo(
                            @"<ProjectLexiconSettings projectSharing=""true"">
  <WritingSystems addToSldr=""true"" />
</ProjectLexiconSettings>"));
        }
        public void Write_EmptyXml_XmlUpdated()
        {
            var settingsStore             = new MemorySettingsStore();
            var projectSettingsDataMapper = new ProjectLexiconSettingsDataMapper(settingsStore);

            var settings = new ProjectLexiconSettings {
                AddWritingSystemsToSldr = true
            };

            projectSettingsDataMapper.Write(settings);

            Assert.That(settingsStore.SettingsElement, Is.EqualTo(XElement.Parse(
                                                                      @"<ProjectLexiconSettings>
  <WritingSystems addToSldr=""true"" />
</ProjectLexiconSettings>")).Using((IEqualityComparer <XNode>) new XNodeEqualityComparer()));
        }
Beispiel #8
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Saves the data in the dialog.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected void SaveInternal()
        {
            var wsContainer = m_cache.ServiceLocator.WritingSystems;

            var userWs = m_cache.ServiceLocator.WritingSystemManager.UserWs;

            m_fProjNameChanged = (m_txtProjName.Text != m_sOrigProjName);
            if (m_txtProjDescription.Text != m_sOrigDescription)
            {
                m_langProj.Description.set_String(userWs, TsStringUtils.MakeString(m_txtProjDescription.Text, userWs));
            }

            var sNewLinkedFilesRootDir = txtExtLnkEdit.Text;

            SaveLinkedFilesChanges(sNewLinkedFilesRootDir);
            m_projectLexiconSettings.ProjectSharing = m_enableProjectSharingCheckBox.Checked;
            m_projectLexiconSettingsDataMapper.Write(m_projectLexiconSettings);
        }