public void Write_EmptyXml_XmlUpdated()
        {
            var settingsStore             = new MemorySettingsStore();
            var projectSettingsDataMapper = new ProjectLexiconSettingsWritingSystemDataMapper(settingsStore);

            var ws1 = new WritingSystemDefinition("qaa-Qaaa-QM-x-kal-Fake-ZG-var1-var2");

            ws1.Language    = new LanguageSubtag(ws1.Language, "Kalaba");
            ws1.Script      = new ScriptSubtag(ws1.Script, "Fake");
            ws1.Region      = new RegionSubtag(ws1.Region, "Zolrog");
            ws1.Variants[0] = new VariantSubtag(ws1.Variants[0], "Custom 1");
            ws1.Variants[1] = new VariantSubtag(ws1.Variants[1], "Custom 2");
            projectSettingsDataMapper.Write(ws1);

            Assert.That(settingsStore.SettingsElement, Is.XmlEqualTo(
                            @"<ProjectLexiconSettings>
  <WritingSystems>
    <WritingSystem id=""qaa-Qaaa-QM-x-kal-Fake-ZG-var1-var2"">
      <Abbreviation>kal</Abbreviation>
      <LanguageName>Kalaba</LanguageName>
      <ScriptName>Fake</ScriptName>
      <RegionName>Zolrog</RegionName>
    </WritingSystem>
  </WritingSystems>
</ProjectLexiconSettings>"));
        }
        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>"));
        }
Exemple #3
0
        public void Remove_NonexistentWritingSystem_DoesNotUpdateXml()
        {
            const string userSettingsXml =
                @"<UserLexiconSettings>
  <WritingSystems>
    <WritingSystem id=""en-US"">
      <LocalKeyboard>en-US_English-IPA</LocalKeyboard>
      <DefaultFontName>Times New Roman</DefaultFontName>
    </WritingSystem>
  </WritingSystems>
</UserLexiconSettings>";

            var settingsStore = new MemorySettingsStore {
                SettingsElement = XElement.Parse(userSettingsXml)
            };
            var userSettingsDataMapper = new UserLexiconSettingsWritingSystemDataMapper(settingsStore);

            userSettingsDataMapper.Remove("fr-FR");
            Assert.That(settingsStore.SettingsElement, Is.XmlEqualTo(
                            @"<UserLexiconSettings>
  <WritingSystems>
    <WritingSystem id=""en-US"">
      <LocalKeyboard>en-US_English-IPA</LocalKeyboard>
      <DefaultFontName>Times New Roman</DefaultFontName>
    </WritingSystem>
  </WritingSystems>
</UserLexiconSettings>"));
        }
        public void Remove_ExistingWritingSystem_UpdatesXml()
        {
            const string projectSettingsXml =
                @"<ProjectLexiconSettings>
  <WritingSystems>
    <WritingSystem id=""qaa-Qaaa-QM-x-kal-Fake-ZG-var1-var2"">
      <Abbreviation>kal</Abbreviation>
      <LanguageName>Kalaba</LanguageName>
      <ScriptName>Fake</ScriptName>
      <RegionName>Zolrog</RegionName>
      <VariantNames>
        <VariantName>Custom 1</VariantName>
        <VariantName>Custom 2</VariantName>
      </VariantNames>
    </WritingSystem>
    <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 ProjectLexiconSettingsWritingSystemDataMapper(settingsStore);

            projectSettingsDataMapper.Remove("fr-FR");
            Assert.That(settingsStore.SettingsElement, Is.XmlEqualTo(
                            @"<ProjectLexiconSettings>
  <WritingSystems>
    <WritingSystem id=""qaa-Qaaa-QM-x-kal-Fake-ZG-var1-var2"">
      <Abbreviation>kal</Abbreviation>
      <LanguageName>Kalaba</LanguageName>
      <ScriptName>Fake</ScriptName>
      <RegionName>Zolrog</RegionName>
      <VariantNames>
        <VariantName>Custom 1</VariantName>
        <VariantName>Custom 2</VariantName>
      </VariantNames>
    </WritingSystem>
  </WritingSystems>
</ProjectLexiconSettings>"));

            projectSettingsDataMapper.Remove("qaa-Qaaa-QM-x-kal-Fake-ZG-var1-var2");
            Assert.That(settingsStore.SettingsElement, Is.XmlEqualTo("<ProjectLexiconSettings />"));
        }
        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_ValidXml_XmlUpdated()
        {
            const string projectSettingsXml =
                @"<ProjectLexiconSettings>
  <WritingSystems>
    <WritingSystem id=""qaa-Qaaa-QM-x-kal-Fake-ZG-var1-var2-var3"">
      <Abbreviation>kal</Abbreviation>
      <LanguageName>Kalaba</LanguageName>
      <ScriptName>Fake</ScriptName>
      <RegionName>Zolrog</RegionName>
    </WritingSystem>
  </WritingSystems>
</ProjectLexiconSettings>";

            var settingsStore = new MemorySettingsStore {
                SettingsElement = XElement.Parse(projectSettingsXml)
            };
            var projectSettingsDataMapper = new ProjectLexiconSettingsWritingSystemDataMapper(settingsStore);
            var ws1 = new WritingSystemDefinition("qaa-Qaaa-QM-x-kal-Fake-ZG-var1-var2-var3");

            ws1.Abbreviation    = "ka";
            ws1.SpellCheckingId = "en_US";
            ws1.LegacyMapping   = "converter";
            ws1.Keyboard        = "Old Keyboard";
            var scd = new SystemCollationDefinition {
                LanguageTag = "snarf"
            };

            ws1.DefaultCollation = scd;
            projectSettingsDataMapper.Write(ws1);

            Assert.That(settingsStore.SettingsElement, Is.XmlEqualTo(
                            @"<ProjectLexiconSettings>
  <WritingSystems>
    <WritingSystem id=""qaa-Qaaa-QM-x-kal-Fake-ZG-var1-var2-var3"">
      <Abbreviation>ka</Abbreviation>
      <SpellCheckingId>en_US</SpellCheckingId>
      <LegacyMapping>converter</LegacyMapping>
      <Keyboard>Old Keyboard</Keyboard>
      <SystemCollation>snarf</SystemCollation>
    </WritingSystem>
  </WritingSystems>
</ProjectLexiconSettings>"));
        }
Exemple #7
0
        public void Write_ValidXml_XmlUpdated()
        {
            const string userSettingsXml =
                @"<UserLexiconSettings>
  <WritingSystems>
    <WritingSystem id=""en-US"">
      <LocalKeyboard>en-US_English-IPA</LocalKeyboard>
      <KnownKeyboards>
        <KnownKeyboard>en-US_English-IPA</KnownKeyboard>
      </KnownKeyboards>
      <DefaultFontName>Times New Roman</DefaultFontName>
    </WritingSystem>
  </WritingSystems>
</UserLexiconSettings>";

            var settingsStore = new MemorySettingsStore {
                SettingsElement = XElement.Parse(userSettingsXml)
            };
            var userSettingsDataMapper = new UserLexiconSettingsWritingSystemDataMapper(settingsStore);
            var ws1 = new WritingSystemDefinition("en-US");

            ws1.LocalKeyboard     = Keyboard.Controller.CreateKeyboard("en-US_English", KeyboardFormat.Unknown, Enumerable.Empty <string>());
            ws1.DefaultFont       = null;
            ws1.DefaultFontSize   = 12;
            ws1.IsGraphiteEnabled = false;
            userSettingsDataMapper.Write(ws1);

            Assert.That(settingsStore.SettingsElement, Is.XmlEqualTo(
                            @"<UserLexiconSettings>
  <WritingSystems>
    <WritingSystem id=""en-US"">
      <LocalKeyboard>en-US_English</LocalKeyboard>
      <KnownKeyboards>
        <KnownKeyboard>en-US_English</KnownKeyboard>
      </KnownKeyboards>
      <DefaultFontSize>12</DefaultFontSize>
      <IsGraphiteEnabled>false</IsGraphiteEnabled>
    </WritingSystem>
  </WritingSystems>
</UserLexiconSettings>"));
        }
        public void Remove_NonexistentWritingSystem_DoesNotUpdateFile()
        {
            const string projectSettingsXml =
                @"<ProjectLexiconSettings>
  <WritingSystems>
    <WritingSystem id=""qaa-Qaaa-QM-x-kal-Fake-ZG-var1-var2"">
      <Abbreviation>kal</Abbreviation>
      <LanguageName>Kalaba</LanguageName>
      <ScriptName>Fake</ScriptName>
      <RegionName>Zolrog</RegionName>
      <VariantNames>
        <VariantName>Custom 1</VariantName>
        <VariantName>Custom 2</VariantName>
      </VariantNames>
    </WritingSystem>
  </WritingSystems>
</ProjectLexiconSettings>";

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

            projectSettingsDataMapper.Remove("fr-FR");
            Assert.That(settingsStore.SettingsElement, Is.XmlEqualTo(
                            @"<ProjectLexiconSettings>
  <WritingSystems>
    <WritingSystem id=""qaa-Qaaa-QM-x-kal-Fake-ZG-var1-var2"">
      <Abbreviation>kal</Abbreviation>
      <LanguageName>Kalaba</LanguageName>
      <ScriptName>Fake</ScriptName>
      <RegionName>Zolrog</RegionName>
      <VariantNames>
        <VariantName>Custom 1</VariantName>
        <VariantName>Custom 2</VariantName>
      </VariantNames>
    </WritingSystem>
  </WritingSystems>
</ProjectLexiconSettings>"));
        }
Exemple #9
0
        public void Write_EmptyXml_XmlUpdated()
        {
            var settingsStore          = new MemorySettingsStore();
            var userSettingsDataMapper = new UserLexiconSettingsWritingSystemDataMapper(settingsStore);

            var ws1 = new WritingSystemDefinition("en-US");

            ws1.LocalKeyboard = Keyboard.Controller.CreateKeyboard("en-US_English-IPA", KeyboardFormat.Unknown, Enumerable.Empty <string>());
            ws1.DefaultFont   = new FontDefinition("Times New Roman");
            userSettingsDataMapper.Write(ws1);

            Assert.That(settingsStore.SettingsElement, Is.XmlEqualTo(
                            @"<UserLexiconSettings>
  <WritingSystems>
    <WritingSystem id=""en-US"">
      <LocalKeyboard>en-US_English-IPA</LocalKeyboard>
      <KnownKeyboards>
        <KnownKeyboard>en-US_English-IPA</KnownKeyboard>
      </KnownKeyboards>
      <DefaultFontName>Times New Roman</DefaultFontName>
    </WritingSystem>
  </WritingSystems>
</UserLexiconSettings>"));
        }