コード例 #1
0
        public void GetLdmlFile_SldrCacheDestinationPath_ReturnsCacheFile()
        {
            using (var environment = new TestEnvironment(false))
            {
                string       filename;
                const string ietfLanguageTag = "en-GB";

                var sldrStatus = Sldr.GetLdmlFile(Sldr.SldrCachePath, ietfLanguageTag, new[] { "characters" }, out filename);
                if (sldrStatus == SldrStatus.UnableToConnectToSldr)
                {
                    Assert.Ignore("Ignored becuase SLDR is offline.");
                }

                Assert.That(sldrStatus, Is.EqualTo(SldrStatus.FromSldr));

                string filePath = Path.Combine(Sldr.SldrCachePath, filename);
                AssertThatXmlIn.File(filePath).HasAtLeastOneMatchForXpath("/ldml/identity/language[@type='en']", environment.NamespaceManager);
                AssertThatXmlIn.File(filePath).HasNoMatchForXpath("/ldml/identity/script", environment.NamespaceManager);
                AssertThatXmlIn.File(filePath).HasAtLeastOneMatchForXpath("/ldml/identity/territory[@type='GB']", environment.NamespaceManager);

                // Verify draft is approved and uid doesn't exist
                AssertThatXmlIn.File(filePath).HasAtLeastOneMatchForXpath("/ldml/identity/special/sil:identity[@draft='approved']", environment.NamespaceManager);
                AssertThatXmlIn.File(filePath).HasAtLeastOneMatchForXpath("/ldml/identity/special/sil:identity[not(@uid)]", environment.NamespaceManager);
            }
        }
コード例 #2
0
ファイル: SldrTests.cs プロジェクト: sujeffreyl/libpalaso
 public void GetLdmlFile_DefaultDownloadsAllTopLevelElements()
 {
     using (var environment = new TestEnvironment(false))
     {
         string       filename;
         const string ietfLanguageTag = "en-US";
         var          sldrStatus      = Sldr.GetLdmlFile(environment.FilePath, ietfLanguageTag, out filename);
         if (sldrStatus == SldrStatus.UnableToConnectToSldr)
         {
             Assert.Ignore("Ignored becuase SLDR is offline.");
         }
         Assert.That(sldrStatus, Is.EqualTo(SldrStatus.FromSldr));
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[identity]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[localeDisplayNames]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[layout]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[contextTransforms]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[characters]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[delimiters]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[dates]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[numbers]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[units]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[listPatterns]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[collations]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[posix]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[segmentations]", environment.NamespaceManager);
         AssertThatXmlIn.File(Path.Combine(environment.FilePath, filename)).HasAtLeastOneMatchForXpath("/ldml[metadata]", environment.NamespaceManager);
     }
 }
コード例 #3
0
        public void Initialize_SkipsBadFile_DataProblemInLDMLFont()
        {
            using (var e = CreateTemporaryFolder(TestContext.CurrentContext.Test.Name))
            {
                var versionPath = Path.Combine(e.Path, LdmlDataMapper.CurrentLdmlLibraryVersion.ToString());
                Directory.CreateDirectory(versionPath);
                var          badFile  = Path.Combine(versionPath, "en.ldml");
                const string ldmlData = @"<?xml version='1.0' encoding='utf-8'?>
					<ldml>
						<identity>
							<version number=''/>
							<generation date='2020-02-28T18:43:36Z'/>
							<language type='en'/>
							<special xmlns:sil='urn://www.sil.org/ldml/0.1'>
								<sil:identity windowsLCID='1033'/>
							</special>
						</identity>
						<special xmlns:sil='urn://www.sil.org/ldml/0.1'>
							<sil:external-resources>
								<sil:font name='Amdo Classic 1' types='kaboom' />
							</sil:external-resources>
						</special>	 
					</ldml>"                    ;
                File.WriteAllText(badFile, ldmlData);
                var repo = GlobalWritingSystemRepository.InitializeWithBasePath(e.Path, null);
                // main part of test is that we don't get any exception.
                Assert.That(repo.Count, Is.EqualTo(0));
                // original .ldml file should have been renamed
                Assert.That(File.Exists(badFile), Is.False);
                Assert.That(File.Exists(badFile + ".bad"), Is.True);
                Assert.That(File.Exists(Path.Combine(versionPath, "badldml.log")), Is.True);
            }
        }
コード例 #4
0
ファイル: SldrTests.cs プロジェクト: JamesPrabu/libpalaso
        public void GetLdmlFile_CacheFileWithUid_StatusFileFromSldrCache()
        {
            using (var environment = new TestEnvironment())
            {
                string content =
                    @"<?xml version='1.0' encoding='utf-8'?>
<ldml>
	<identity>
		<version number='$Revision: 11161 $'/>
		<generation date='$Date: 2015-01-30 22:33 +0000 $'/>
		<language type='qaa'/>
		<special xmlns:sil='urn://www.sil.org/ldml/0.1'>
			<sil:identity source='cldr' draft='proposed' revid='53d542ba498f40f437f7723e69dcf64dab6c9794' uid='e2ccb575'/>
		</special>
		<script type='Latn'/>
	</identity>
</ldml>".Replace("\'", "\"");
                const string ietfLanguageTag = "qaa";
                // File exists in destination and cache, so uid will be checked
                File.WriteAllText(Path.Combine(environment.FilePath, ietfLanguageTag + ".ldml"), content);
                string filename = Path.Combine(Sldr.SldrCachePath, ietfLanguageTag + "-e2ccb575.ldml");
                File.WriteAllText(filename, content);

                Assert.That(environment.GetLdmlFile(ietfLanguageTag, out filename), Is.EqualTo(SldrStatus.FromCache));
                Assert.That(filename, Is.EqualTo(ietfLanguageTag + ".ldml"));
            }
        }
コード例 #5
0
ファイル: SldrTests.cs プロジェクト: sujeffreyl/libpalaso
        // This depends on when SLDR updates "en-US.ldml" with the revid
        public void GetLdmlFile_NotModified_DoesntDownloadNewFile()
        {
            using (var environment = new TestEnvironment(false))
            {
                // Write
                string       content         = LdmlContentForTests.Version3Identity("en", "", "US", "", "", "12345", "variantName", "", "d9fabd0fa2c615cfdfb3d2b48f403f55145ff16a");
                const string ietfLanguageTag = "en-US";

                // Write content to destination and cache
                File.WriteAllText(Path.Combine(environment.FilePath, ietfLanguageTag + ".ldml"), content);
                File.WriteAllText(Path.Combine(Sldr.SldrCachePath, ietfLanguageTag + ".ldml"), content);

                string filename;
                var    sldrStatus = environment.GetLdmlFile(ietfLanguageTag, out filename);
                if (sldrStatus == SldrStatus.UnableToConnectToSldr)
                {
                    Assert.Ignore("Ignored becuase SLDR is offline.");
                }
                // Call a second time, this should use the Cache now
                sldrStatus = environment.GetLdmlFile(ietfLanguageTag, out filename);
                Assert.That(sldrStatus, Is.EqualTo(SldrStatus.FromCache));
                string filePath = Path.Combine(environment.FilePath, filename);
                AssertThatXmlIn.File(filePath).HasAtLeastOneMatchForXpath("/ldml/identity/special/sil:identity[@source='cldr']", environment.NamespaceManager);
            }
        }
コード例 #6
0
ファイル: SldrTests.cs プロジェクト: JamesPrabu/libpalaso
        public void ReadSilIdentity_GetsRevidAndUid()
        {
            using (var environment = new TestEnvironment())
            {
                string content =
                    @"<?xml version='1.0' encoding='utf-8'?>
<ldml>
	<identity>
		<version number='$Revision: 11161 $'/>
		<generation date='$Date: 2015-01-30 22:33 +0000 $'/>
		<language type='en'/>
		<special xmlns:sil='urn://www.sil.org/ldml/0.1'>
			<sil:identity source='cldr' draft='proposed' revid='53d542ba498f40f437f7723e69dcf64dab6c9794' uid='e2ccb575'/>
		</special>
		<script type='Latn'/>
	</identity>
</ldml>".Replace("\'", "\"");
                const string ietfLanguageTag = "en";
                string       filename        = Path.Combine(environment.FilePath, ietfLanguageTag + ".ldml");
                File.WriteAllText(filename, content);

                string revid, uid;
                Assert.True(Sldr.ReadSilIdentity(filename, out revid, out uid));
                Assert.That(revid, Is.EqualTo("53d542ba498f40f437f7723e69dcf64dab6c9794"));
                Assert.That(uid, Is.EqualTo("e2ccb575"));
            }
        }
コード例 #7
0
ファイル: SldrTests.cs プロジェクト: JamesPrabu/libpalaso
        public void GetLdmlFile_CacheFileWithUidUnknown_StatusFileFromSldrCache()
        {
            using (var environment = new TestEnvironment())
            {
                string content =
                    @"<?xml version='1.0' encoding='utf-8'?>
<ldml>
	<identity>
		<version number='$Revision: 11161 $'/>
		<generation date='$Date: 2015-01-30 22:33 +0000 $'/>
		<language type='qaa'/>
		<special xmlns:sil='urn://www.sil.org/ldml/0.1'>
			<sil:identity source='cldr' draft='proposed' revid='53d542ba498f40f437f7723e69dcf64dab6c9794'/>
		</special>
		<script type='Latn'/>
	</identity>
</ldml>".Replace("\'", "\"");
                const string ietfLanguageTag = "qaa";
                string       filename        = Path.Combine(Sldr.SldrCachePath, ietfLanguageTag + ".ldml");
                // File only exists in cache so uid unknown
                File.WriteAllText(filename, content);

                Assert.That(environment.GetLdmlFile(ietfLanguageTag, out filename), Is.EqualTo(SldrStatus.FromCache));
                string filePath = Path.Combine(environment.FilePath, filename);
                Assert.That(filename, Is.EqualTo(ietfLanguageTag + ".ldml"));
                AssertThatXmlIn.File(filePath).HasAtLeastOneMatchForXpath("/ldml/identity/language[@type='qaa']", environment.NamespaceManager);
                AssertThatXmlIn.File(filePath).HasAtLeastOneMatchForXpath("/ldml/identity/script[@type='Latn']", environment.NamespaceManager);
                AssertThatXmlIn.File(filePath).HasAtLeastOneMatchForXpath("/ldml/identity/special/sil:identity[@draft='proposed']", environment.NamespaceManager);
                AssertThatXmlIn.File(filePath).HasAtLeastOneMatchForXpath("/ldml/identity/special/sil:identity[not(@uid)]", environment.NamespaceManager);
            }
        }
コード例 #8
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>"));
        }
コード例 #9
0
        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_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>"));
        }
コード例 #11
0
        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>"));
        }
コード例 #12
0
        public void DefaultInitializer_HasCorrectPath()
        {
            GlobalWritingSystemRepository repo = GlobalWritingSystemRepository.Initialize();
            string expectedPath = string.Format(".*SIL.WritingSystemRepository.{0}",
                                                LdmlDataMapper.CurrentLdmlLibraryVersion);

            Assert.That(repo.PathToWritingSystems, Is.StringMatching(expectedPath));
        }
コード例 #13
0
 public void Read_SampleLogFile_PopulatesChanges()
 {
     using (var e = new TestEnvironment())
     {
         var log = new WritingSystemChangeLog(new WritingSystemChangeLogDataMapper(e.GetSampleLogFilePath()));
         Assert.That(log.HasChangeFor("aaa"), Is.True);
         Assert.That(log.GetChangeFor("aaa"), Is.EqualTo("ddd"));
     }
 }
コード例 #14
0
 public void PathConstructor_HasCorrectPath()
 {
     using (var e = CreateTemporaryFolder(TestContext.CurrentContext.Test.Name))
     {
         var repo = new GlobalWritingSystemRepository(e.Path);
         Assert.That(repo.PathToWritingSystems,
                     Is.StringMatching($".*PathConstructor_HasCorrectPath.*{LdmlDataMapper.CurrentLdmlLibraryVersion}"));
     }
 }
        public void CloneCopiesUrls()
        {
            var original = new SpellCheckDictionaryDefinition(SpellCheckDictionaryFormat.Hunspell);

            original.Urls.Add("url1");
            original.Urls.Add("url2");
            SpellCheckDictionaryDefinition copy = original.Clone();

            Assert.That(copy.Urls, Is.EqualTo(new string[] { "url1", "url2" }));
        }
コード例 #16
0
 public void PathConstructor_HasCorrectPath()
 {
     using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
     {
         var    repo         = new GlobalWritingSystemRepository(e.Path);
         string expectedPath = string.Format(".*GlobalWritingSystemRepositoryTests.{0}",
                                             LdmlDataMapper.CurrentLdmlLibraryVersion);
         Assert.That(repo.PathToWritingSystems, Is.StringMatching(expectedPath));
     }
 }
コード例 #17
0
ファイル: SldrTests.cs プロジェクト: JamesPrabu/libpalaso
        public void GetLdmlFile_Fonipa_StatusFileNotFound()
        {
            using (var environment = new TestEnvironment())
            {
                string       filename;
                const string ietfLanguageTag = "lo-LA-fonipa";

                Assert.That(environment.GetLdmlFile(ietfLanguageTag, out filename), Is.EqualTo(SldrStatus.NotFound));
            }
        }
コード例 #18
0
        public void CloneCopiesUrls()
        {
            var original = new FontDefinition("font1");

            original.Urls.Add("url1");
            original.Urls.Add("url2");
            FontDefinition copy = original.Clone();

            Assert.That(copy.Urls, Is.EqualTo(new string[] { "url1", "url2" }));
        }
コード例 #19
0
        public void CloneCopiesCharacters()
        {
            var original = new CharacterSetDefinition("main");

            original.Characters.Add("a");
            original.Characters.Add("b");
            CharacterSetDefinition copy = original.Clone();

            Assert.That(copy.Characters, Is.EquivalentTo(new string[] { "a", "b" }));
        }
コード例 #20
0
ファイル: SldrTests.cs プロジェクト: JamesPrabu/libpalaso
        public void GetLdmlFile_UnknownLanguage_StatusFileNotFound()
        {
            using (var environment = new TestEnvironment(false))
            {
                string       filename;
                const string ietfLanguageTag = "qaa";

                Assert.That(environment.GetLdmlFile(ietfLanguageTag, out filename), Is.EqualTo(SldrStatus.NotFound));
            }
        }
コード例 #21
0
 public void Set_NewWritingSystem_SetsId()
 {
     using (var e = new TemporaryFolder("GlobalWritingSystemRepositoryTests"))
     {
         var repo = new GlobalWritingSystemRepository(e.Path);
         var ws   = new WritingSystemDefinition("en-US");
         Assert.That(ws.Id, Is.Null);
         repo.Set(ws);
         Assert.That(ws.Id, Is.EqualTo("en-US"));
     }
 }
コード例 #22
0
ファイル: SldrTests.cs プロジェクト: JamesPrabu/libpalaso
        public void GetLdmlFile_LanguageTagWithSuppressedScript_DownloadsFile()
        {
            using (var environment = new TestEnvironment(false))
            {
                string       filename;
                const string ietfLanguageTag = "oro";

                Assert.That(environment.GetLdmlFile(ietfLanguageTag, out filename), Is.EqualTo(SldrStatus.FromSldr));
                Assert.That(File.Exists(Path.Combine(environment.FilePath, filename)), Is.True);
            }
        }
コード例 #23
0
 public void Set_NewWritingSystem_SetsId()
 {
     using (var e = CreateTemporaryFolder(TestContext.CurrentContext.Test.Name))
     {
         var repo = new GlobalWritingSystemRepository(e.Path);
         var ws   = new WritingSystemDefinition("en-US");
         Assert.That(ws.Id, Is.Null);
         repo.Set(ws);
         Assert.That(ws.Id, Is.EqualTo("en-US"));
     }
 }
コード例 #24
0
 public void FindOrphans_StaticListOfIds_DuplicateIsCreated()
 {
     using (var e = new TestEnvironment("boglang-Zxxx-bogusws", "boglang-bogusws-Zxxx"))
     {
         var wss = new List <string>(e.GetIdsFromFile);
         WritingSystemOrphanFinder.FindOrphans(wss, e.ReplaceIdInFile, e.WritingSystemRepository);
         Assert.That(e.WritingSystemRepository.Count, Is.EqualTo(2));
         Assert.That(e.WritingSystemRepository.Get("qaa-Zxxx-x-boglang-bogusws"), Is.Not.Null);
         Assert.That(e.WritingSystemRepository.Get("qaa-Zxxx-x-boglang-bogusws-dupl0"), Is.Not.Null);
         Assert.That(e.FileContent, Is.EqualTo("|qaa-Zxxx-x-boglang-bogusws||qaa-Zxxx-x-boglang-bogusws||qaa-Zxxx-x-boglang-bogusws-dupl0|"));
     }
 }
コード例 #25
0
 public void FindOrphans_NoOrphansFound_WritingSystemRepoAndFileUntouched()
 {
     using (var e = new TestEnvironment("en", "en"))
     {
         var englishWs = new WritingSystemDefinition("en");
         e.WritingSystemRepository.Set(englishWs);
         WritingSystemOrphanFinder.FindOrphans(e.GetIdsFromFile, e.ReplaceIdInFile, e.WritingSystemRepository);
         Assert.That(e.WritingSystemRepository.Count, Is.EqualTo(1));
         Assert.That(e.WritingSystemRepository.Get("en"), Is.EqualTo(englishWs));
         Assert.That(e.FileContent, Is.EqualTo("|en||en||en|"));
     }
 }
コード例 #26
0
        public void Read_EmptyXml_NothingSet()
        {
            var userSettingsDataMapper = new UserLexiconSettingsWritingSystemDataMapper(new MemorySettingsStore());

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

            userSettingsDataMapper.Read(ws1);

            Assert.That(ws1.LocalKeyboard, Is.EqualTo(Keyboard.Controller.DefaultKeyboard));
            Assert.That(ws1.DefaultFont, Is.Null);
            Assert.That(ws1.DefaultFontSize, Is.EqualTo(0));
            Assert.That(ws1.IsGraphiteEnabled, Is.True);
        }
コード例 #27
0
ファイル: SldrTests.cs プロジェクト: JamesPrabu/libpalaso
        public void LanguageTags_OlderCachedAllTagsSldrOffline_UseEmbeddedAllTags()
        {
            using (new TestEnvironment())
            {
                string allTagsPath = Path.Combine(Sldr.SldrCachePath, "alltags.json");

                File.WriteAllText(allTagsPath, "[ { \"full\": \"en-Latn-GB\", \"iso639_3\": \"eng\", \"name\": \"English\", \"region\": \"GB\", \"sldr\": true, \"tag\": \"en-GB\" } ]");
                File.SetLastWriteTime(allTagsPath, new DateTime(2000, 1, 1, 12, 0, 0));

                Assert.That(Sldr.LanguageTags.Count, Is.GreaterThan(1));
                Assert.That(File.Exists(allTagsPath), Is.False);
            }
        }
コード例 #28
0
 public void FindOrphans_OrphanFoundIsNotValidRfcTag_OrphanIsMadeConformAndIsAddedWritingSystemRepoAndWritingSystemIsChangedInFile()
 {
     using (var e = new TestEnvironment("en", "bogusws"))
     {
         var englishWs = new WritingSystemDefinition("en");
         e.WritingSystemRepository.Set(englishWs);
         WritingSystemOrphanFinder.FindOrphans(e.GetIdsFromFile, e.ReplaceIdInFile, e.WritingSystemRepository);
         Assert.That(e.WritingSystemRepository.Count, Is.EqualTo(2));
         Assert.That(e.WritingSystemRepository.Get("en"), Is.EqualTo(englishWs));
         Assert.That(e.WritingSystemRepository.Get("qaa-x-bogusws"), Is.Not.Null);
         Assert.That(e.FileContent, Is.EqualTo("|en||en||qaa-x-bogusws|"));
     }
 }
コード例 #29
0
 public void FindOrphans_OrphanFoundIsValidRfcTag_WritingsystemIsAddedToWritingSystemRepoAndFileUntouched()
 {
     using (var e = new TestEnvironment("en", "de"))
     {
         var englishWs = new WritingSystemDefinition("en");
         e.WritingSystemRepository.Set(englishWs);
         WritingSystemOrphanFinder.FindOrphans(e.GetIdsFromFile, e.ReplaceIdInFile, e.WritingSystemRepository);
         Assert.That(e.WritingSystemRepository.Count, Is.EqualTo(2));
         Assert.That(e.WritingSystemRepository.Get("en"), Is.EqualTo(englishWs));
         Assert.That(e.WritingSystemRepository.Get("de"), Is.Not.Null);
         Assert.That(e.FileContent, Is.EqualTo("|en||en||de|"));
     }
 }
コード例 #30
0
        public void Read_ValidXml_SetsAllProperties()
        {
            const string userSettingsXml =
                @"<UserLexiconSettings>
  <WritingSystems>
    <WritingSystem id=""en-US"">
      <LocalKeyboard>en-US_English-IPA</LocalKeyboard>
      <KnownKeyboards>
        <KnownKeyboard>en-US_English</KnownKeyboard>
      </KnownKeyboards>
      <DefaultFontName>Times New Roman</DefaultFontName>
    </WritingSystem>
    <WritingSystem id=""fr-FR"">
      <DefaultFontSize>12</DefaultFontSize>
      <IsGraphiteEnabled>false</IsGraphiteEnabled>
    </WritingSystem>
  </WritingSystems>
</UserLexiconSettings>";

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

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

            userSettingsDataMapper.Read(ws1);

            Assert.That(ws1.LocalKeyboard.Id, Is.EqualTo("en-US_English-IPA"));
            Assert.That(ws1.KnownKeyboards[1].Id, Is.EqualTo("en-US_English"));
            Assert.That(ws1.DefaultFont.Name, Is.EqualTo("Times New Roman"));
            Assert.That(ws1.DefaultFontSize, Is.EqualTo(0));
            Assert.That(ws1.IsGraphiteEnabled, Is.True);

            var ws2 = new WritingSystemDefinition("fr-FR");

            userSettingsDataMapper.Read(ws2);

            Assert.That(ws2.LocalKeyboard, Is.EqualTo(Keyboard.Controller.DefaultKeyboard));
            Assert.That(ws2.DefaultFont, Is.Null);
            Assert.That(ws2.DefaultFontSize, Is.EqualTo(12));
            Assert.That(ws2.IsGraphiteEnabled, Is.False);

            var ws3 = new WritingSystemDefinition("es");

            userSettingsDataMapper.Read(ws3);

            Assert.That(ws3.LocalKeyboard, Is.EqualTo(Keyboard.Controller.DefaultKeyboard));
            Assert.That(ws3.DefaultFont, Is.Null);
            Assert.That(ws3.DefaultFontSize, Is.EqualTo(0));
            Assert.That(ws3.IsGraphiteEnabled, Is.True);
        }