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()));
        }
        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 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()));
		}
예제 #4
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));
            }
        }
예제 #5
0
 private void InitializeProjectSharingTab()
 {
     m_projectLexiconSettingsDataMapper =
         new ProjectLexiconSettingsDataMapper(m_cache.ServiceLocator.DataSetup.ProjectSettingsStore);
     m_projectLexiconSettings = new ProjectLexiconSettings();
     m_projectLexiconSettingsDataMapper.Read(m_projectLexiconSettings);
     m_enableProjectSharingCheckBox.Checked = m_projectLexiconSettings.ProjectSharing;
 }
		public void Read_EmptyXml_NothingSet()
		{
			var projectSettingsDataMapper = new ProjectLexiconSettingsDataMapper(new MemorySettingsStore());

			var settings = new ProjectLexiconSettings();
			projectSettingsDataMapper.Read(settings);

			Assert.That(settings.AddWritingSystemsToSldr, Is.False);
		}
예제 #7
0
		/// <summary/>
		public static bool IsProjectSharingEnabled(string projectFolder)
		{
			ISettingsStore settingStore =
				new FileSettingsStore(LexiconSettingsFileHelper.GetProjectLexiconSettingsPath(projectFolder));
			var settingsMapper = new ProjectLexiconSettingsDataMapper(settingStore);
			var settings = new ProjectLexiconSettings();
			settingsMapper.Read(settings);
			return settings.ProjectSharing;
		}
        public void Read_EmptyXml_NothingSet()
        {
            var projectSettingsDataMapper = new ProjectLexiconSettingsDataMapper(new MemorySettingsStore());

            var settings = new ProjectLexiconSettings();

            projectSettingsDataMapper.Read(settings);

            Assert.That(settings.AddWritingSystemsToSldr, Is.False);
        }
		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()));
        }
		public void Read_ValidXml_SetsAllProperties()
		{
			const string projectSettingsXml =
@"<ProjectLexiconSettings>
  <WritingSystems addToSldr=""true"">
    <WritingSystem id=""fr-FR"">
      <SpellCheckingId>fr_FR</SpellCheckingId>
      <LegacyMapping>converter</LegacyMapping>
      <Keyboard>Old Keyboard</Keyboard>
    </WritingSystem>
  </WritingSystems>
</ProjectLexiconSettings>";

			var projectSettingsDataMapper = new ProjectLexiconSettingsDataMapper(new MemorySettingsStore {SettingsElement = XElement.Parse(projectSettingsXml)});

			var settings = new ProjectLexiconSettings();
			projectSettingsDataMapper.Read(settings);
			Assert.That(settings.AddWritingSystemsToSldr, Is.True);
		}
        public void Read_ValidXml_SetsAllProperties()
        {
            const string projectSettingsXml =
                @"<ProjectLexiconSettings>
  <WritingSystems addToSldr=""true"">
    <WritingSystem id=""fr-FR"">
      <SpellCheckingId>fr_FR</SpellCheckingId>
      <LegacyMapping>converter</LegacyMapping>
      <Keyboard>Old Keyboard</Keyboard>
    </WritingSystem>
  </WritingSystems>
</ProjectLexiconSettings>";

            var projectSettingsDataMapper = new ProjectLexiconSettingsDataMapper(new MemorySettingsStore {
                SettingsElement = XElement.Parse(projectSettingsXml)
            });

            var settings = new ProjectLexiconSettings();

            projectSettingsDataMapper.Read(settings);
            Assert.That(settings.AddWritingSystemsToSldr, Is.True);
        }