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 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>"));
        }
        public void Remove_FinalWritingSystem_PreservesSettings()
        {
            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 settingsStore = new MemorySettingsStore {
                SettingsElement = XElement.Parse(projectSettingsXml)
            };
            var projectSettingsDataMapper = new ProjectLexiconSettingsWritingSystemDataMapper(settingsStore);

            projectSettingsDataMapper.Remove("fr-FR");
            Assert.That(settingsStore.SettingsElement, Is.EqualTo(XElement.Parse(
                                                                      @"<ProjectLexiconSettings>
  <WritingSystems addToSldr=""true""/>
</ProjectLexiconSettings>")).Using((IEqualityComparer <XNode>) new XNodeEqualityComparer()));
        }
		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.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>
      <VariantNames>
        <VariantName>Custom 1</VariantName>
        <VariantName>Custom 2</VariantName>
      </VariantNames>
    </WritingSystem>
  </WritingSystems>
</ProjectLexiconSettings>")).Using((IEqualityComparer<XNode>) new XNodeEqualityComparer()));
		}
		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.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>
      <VariantNames>
        <VariantName>Custom 1</VariantName>
        <VariantName>Custom 2</VariantName>
      </VariantNames>
    </WritingSystem>
  </WritingSystems>
</ProjectLexiconSettings>")).Using((IEqualityComparer<XNode>) new XNodeEqualityComparer()));

			projectSettingsDataMapper.Remove("qaa-Qaaa-QM-x-kal-Fake-ZG-var1-var2");
			Assert.That(settingsStore.SettingsElement, Is.EqualTo(XElement.Parse("<ProjectLexiconSettings />")).Using((IEqualityComparer<XNode>) new XNodeEqualityComparer()));
		}