示例#1
0
 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);
     }
 }
示例#2
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);
            }
        }
示例#3
0
        public void GetLdmlFile_BadDirName_Throws()
        {
            const string path            = "/dev/null/";
            const string ietfLanguageTag = "en";
            string       filename;

            Assert.Throws <DirectoryNotFoundException>(
                () => Sldr.GetLdmlFile(path, ietfLanguageTag, out filename)
                );
        }
示例#4
0
        public void GetLdmlFile_EmptyPath_Throws()
        {
            string       path            = string.Empty;
            const string ietfLanguageTag = "en";
            string       filename;

            Assert.Throws <ArgumentException>(
                () => Sldr.GetLdmlFile(path, ietfLanguageTag, out filename)
                );
        }
示例#5
0
 public SldrStatus GetLdmlFile(string ietfLanguageTag, out string filename)
 {
     return(Sldr.GetLdmlFile(FolderContainingLdml.Path, ietfLanguageTag, new List <string> {
         "characters"
     }, out filename));
 }