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>
  <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>"));
        }
		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.EqualTo(XElement.Parse(
@"<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>")).Using((IEqualityComparer<XNode>) new XNodeEqualityComparer()));
		}
		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.EqualTo(XElement.Parse(
@"<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>")).Using((IEqualityComparer<XNode>) new XNodeEqualityComparer()));
		}