Exemplo n.º 1
0
        public void NestedGroupsAreCorrectlyRepresented()
        {
            var bundle = new Bundle();
            var doc    = new Document();
            var group1 = new PropertyGroup("content");
            var group2 = new PropertyGroup("nestedContent");
            var prop2  = new Property("title", "my content");

            group2.Containers.Add(prop2);
            group1.Containers.Add(group2);
            doc.Containers.Add(group1);
            bundle.Documents.Add(doc);

            ISourceExtractor extractor = new SourceExtractorFromBundle(bundle);
            var xliffModel             = extractor.Extract("en-US", "it-IT");

            var xliffGroup1 = xliffModel.Files[0].Containers[0] as Group;
            var actual      = xliffGroup1.Id;

            Assert.AreEqual("g1", actual);

            var xliffGroup2 = xliffGroup1.Containers[0] as Group;
            var actual2     = xliffGroup2.Id;

            Assert.AreEqual("g2", actual2);

            var unit = xliffGroup2.Containers[0] as Unit;

            Assert.IsNotNull(unit);
            Assert.AreEqual("#/f=f1/g=g1/g=g2/u=u1", unit.SelectorPath);
        }
Exemplo n.º 2
0
        public void PropertiesInsideDifferentGroupsGetsDifferentIds()
        {
            var bundle = new Bundle();
            var doc    = new Document();
            var group1 = new PropertyGroup("content");
            var prop1  = new Property("title", "my content");

            group1.Containers.Add(prop1);
            doc.Containers.Add(group1);
            var group2 = new PropertyGroup("content");
            var prop2  = new Property("title", "my content");

            group2.Containers.Add(prop2);
            doc.Containers.Add(group2);
            bundle.Documents.Add(doc);

            ISourceExtractor extractor = new SourceExtractorFromBundle(bundle);
            var xliffModel             = extractor.Extract("en-US", "it-IT");

            var xliffGroup1 = xliffModel.Files[0].Containers[0] as Group;
            var unit1       = xliffGroup1.Containers[0] as Unit;

            Assert.AreEqual("u1", unit1.Id);
            Assert.AreEqual("#/f=f1/g=g1/u=u1", unit1.SelectorPath);

            var xliffGroup2 = xliffModel.Files[0].Containers[1] as Group;
            var unit2       = xliffGroup2.Containers[0] as Unit;

            Assert.AreEqual("u2", unit2.Id);
            Assert.AreEqual("#/f=f1/g=g2/u=u2", unit2.SelectorPath);
        }
Exemplo n.º 3
0
        public void FileWithOnePropertyWritesToXliffFileWithOneUnit()
        {
            var bundle = EmbeddedFilesReader.ReadString("XliffLib.Test.TestFiles.OnePropertyInRoot.json").ToBundle();

            ISourceExtractor extractor = new SourceExtractorFromBundle(bundle);
            var xliffModel             = extractor.Extract("en-US", "it-IT");

            var actual = xliffModel.Files[0].Containers.Count;

            Assert.AreEqual(1, actual);
            Assert.IsAssignableFrom <Unit>(xliffModel.Files[0].Containers[0]);
        }
Exemplo n.º 4
0
        public void NoMetadataInXliffWhenNoAttributesOnDocumnent()
        {
            var bundle = new Bundle();
            var doc    = new Document();

            bundle.Documents.Add(doc);

            ISourceExtractor extractor = new SourceExtractorFromBundle(bundle);
            var xliffModel             = extractor.Extract("en-US", "it-IT");

            Assert.IsNull(xliffModel.Files[0].Metadata);
        }
Exemplo n.º 5
0
        public void MetadataContainsOneGroupInXliffWhenAttributesOnDocument()
        {
            var bundle = new Bundle();
            var doc    = new Document();

            doc.Attributes.Add("CmsId", "123456");
            bundle.Documents.Add(doc);

            ISourceExtractor extractor = new SourceExtractorFromBundle(bundle);
            var xliffModel             = extractor.Extract("en-US", "it-IT");

            Assert.AreEqual(1, xliffModel.Files[0].Metadata.Groups.Count);
        }
Exemplo n.º 6
0
        public void BundleWithOneDocumentWritesToXliffDocumentWithOneFile()
        {
            var bundle = new Bundle();
            var doc    = new Document();

            bundle.Documents.Add(doc);

            ISourceExtractor extractor = new SourceExtractorFromBundle(bundle);
            var xliffModel             = extractor.Extract("en-US", "it-IT");

            var actual = xliffModel.Files.Count;

            Assert.AreEqual(1, actual);
        }
Exemplo n.º 7
0
        public void TargetLanguageIsCorrectlyRepresentedInXliff()
        {
            var bundle = new Bundle();
            var doc    = new Document();
            var prop   = new Property("content", "my content");

            doc.Containers.Add(prop);
            bundle.Documents.Add(doc);

            ISourceExtractor extractor = new SourceExtractorFromBundle(bundle);
            var xliffModel             = extractor.Extract("en-US", "it-IT");

            Assert.AreEqual("it-IT", xliffModel.TargetLanguage);
        }
Exemplo n.º 8
0
        public void NoMetadataInXliffWhenNoAttributesOnContentElement()
        {
            var bundle = new Bundle();
            var doc    = new Document();
            var group  = new PropertyGroup("content");

            doc.Containers.Add(group);
            bundle.Documents.Add(doc);

            ISourceExtractor extractor = new SourceExtractorFromBundle(bundle);
            var xliffModel             = extractor.Extract("en-US", "it-IT");

            Assert.IsNull(xliffModel.Files[0].Containers[0].Metadata);
        }
Exemplo n.º 9
0
        public void MetadataContainsOneGroupInXliffWhenAttributesOnContentElement()
        {
            var bundle = new Bundle();
            var doc    = new Document();
            var group  = new PropertyGroup("content");

            doc.Containers.Add(group);
            bundle.Documents.Add(doc);
            group.Attributes.Add("CmsPropertyName", "propertyName");

            ISourceExtractor extractor = new SourceExtractorFromBundle(bundle);
            var xliffModel             = extractor.Extract("en-US", "it-IT");

            Assert.AreEqual(1, xliffModel.Files[0].Containers[0].Metadata.Groups.Count);
        }
Exemplo n.º 10
0
        public void MetadataSectionRightValueContainsMetadataInXliffWhenAttributesOnDocument()
        {
            var bundle = new Bundle();
            var doc    = new Document();

            doc.Attributes.Add("CmsId", "123456");
            bundle.Documents.Add(doc);

            ISourceExtractor extractor = new SourceExtractorFromBundle(bundle);
            var xliffModel             = extractor.Extract("en-US", "it-IT");

            var meta = xliffModel.Files[0].Metadata.Groups[0].Containers[0] as Meta;

            Assert.AreEqual("123456", meta.NonTranslatableText);
            Assert.AreEqual("CmsId", meta.Type);
        }
Exemplo n.º 11
0
        public void FileWithOnePropertyGroupWritesToXliffFileWithOneGroup()
        {
            var bundle = new Bundle();
            var doc    = new Document();
            var group  = new PropertyGroup("content");

            doc.Containers.Add(group);
            bundle.Documents.Add(doc);

            ISourceExtractor extractor = new SourceExtractorFromBundle(bundle);
            var xliffModel             = extractor.Extract("en-US", "it-IT");

            var actual = xliffModel.Files[0].Containers.Count;

            Assert.AreEqual(1, actual);
            Assert.IsAssignableFrom <Group>(xliffModel.Files[0].Containers[0]);
        }
Exemplo n.º 12
0
        public void XliffUnitKeepsNameOfProperty()
        {
            var bundle = new Bundle();
            var doc    = new Document();
            var prop   = new Property("content", "my content");

            doc.Containers.Add(prop);
            bundle.Documents.Add(doc);

            ISourceExtractor extractor = new SourceExtractorFromBundle(bundle);
            var xliffModel             = extractor.Extract("en-US", "it-IT");

            var unit   = xliffModel.Files[0].Containers[0] as Unit;
            var actual = unit.Name;

            Assert.AreEqual("content", actual);
        }
Exemplo n.º 13
0
        public void XliffGroupKeepsNameOfPropertyGroup()
        {
            var bundle = new Bundle();
            var doc    = new Document();
            var group  = new PropertyGroup("content");

            doc.Containers.Add(group);
            bundle.Documents.Add(doc);

            ISourceExtractor extractor = new SourceExtractorFromBundle(bundle);
            var xliffModel             = extractor.Extract("en-US", "it-IT");

            var xliffGroup1 = xliffModel.Files[0].Containers[0] as Group;
            var actual      = xliffGroup1.Name;

            Assert.AreEqual("content", actual);
        }
Exemplo n.º 14
0
        public void HtmlValuesAreEncodedIntoCData()
        {
            var bundle = new Bundle();
            var doc    = new Document();
            var prop   = new Property("content", "<p>content</p>");

            doc.Containers.Add(prop);
            bundle.Documents.Add(doc);

            ISourceExtractor extractor = new SourceExtractorFromBundle(bundle);
            var xliffModel             = extractor.Extract("en-US", "it-IT");

            var unit    = xliffModel.Files[0].Containers[0] as Unit;
            var segment = unit.Resources[0] as Segment;
            var actual  = segment.Source.Text[0] as CDataTag;

            Assert.IsNotNull(actual);
        }
Exemplo n.º 15
0
        public void MetadataSectionRightValueContainsMetadataInXliffWhenAttributesOnContentElement()
        {
            var bundle = new Bundle();
            var doc    = new Document();
            var group  = new PropertyGroup("content");

            doc.Containers.Add(group);
            bundle.Documents.Add(doc);
            group.Attributes.Add("CmsPropertyName", "propertyName");

            ISourceExtractor extractor = new SourceExtractorFromBundle(bundle);
            var xliffModel             = extractor.Extract("en-US", "it-IT");

            var meta = xliffModel.Files[0].Containers[0].Metadata.Groups[0].Containers[0] as Meta;

            Assert.AreEqual("propertyName", meta.NonTranslatableText);
            Assert.AreEqual("CmsPropertyName", meta.Type);
        }
Exemplo n.º 16
0
        public void PropertyInsideFirstLevelGroupGetsRightId()
        {
            var bundle = new Bundle();
            var doc    = new Document();
            var group  = new PropertyGroup("content");
            var prop   = new Property("title", "my content");

            group.Containers.Add(prop);
            doc.Containers.Add(group);
            bundle.Documents.Add(doc);

            ISourceExtractor extractor = new SourceExtractorFromBundle(bundle);
            var xliffModel             = extractor.Extract("en-US", "it-IT");

            var xliffGroup = xliffModel.Files[0].Containers[0] as Group;
            var actual     = xliffGroup.Containers[0].Id;

            Assert.AreEqual("u1", actual);
        }