Example #1
0
        public void XliffReader_XLIFFSupportSniffer_ReturnsEqual(Enumerators.XLIFFSupport support)
        {
            // arrange
            var sniffer        = new XliffSniffer();
            var segmentBuilder = new SegmentBuilder();
            var xliffReader    = new XliffReder(sniffer, segmentBuilder);
            //var pocoFilterManager = new PocoFilterManager(false);
            var fileTypeManager = DefaultFileTypeManager.CreateInstance(true);
            var importOptions   = new ImportOptions();
            var analysisBands   = new List <AnalysisBand>();
            var sdlxliffWriter  = new SdlxliffWriter(fileTypeManager, segmentBuilder, importOptions, analysisBands);

            var testFile = support == Enumerators.XLIFFSupport.xliff12polyglot
                                ? _testFilesUtil.GetSampleFilePath("Xliff12", "Polyglot", "QuotesSample.docx.sdlxliff.xliff")
                                : _testFilesUtil.GetSampleFilePath("Xliff12", "xsi", "QuotesSample.docx.sdlxliff.xliff");
            var sdlxliffFile = _testFilesUtil.GetSampleFilePath("Sdlxliff", "QuotesSample.docx.sdlxliff");

            // act
            var xliff      = xliffReader.ReadXliff(testFile);
            var outputFile = sdlxliffFile + ".out.sdlxliff";
            var success    = sdlxliffWriter.UpdateFile(xliff, sdlxliffFile, outputFile);

            // assert
            Assert.Equal(support, xliff.Support);
        }
Example #2
0
        public XliffWriter(Enumerators.XLIFFSupport support)
        {
            switch (support)
            {
            case Enumerators.XLIFFSupport.xliff12polyglot:
                _writer = new Xliff12PolyglotWriter();
                break;

            case Enumerators.XLIFFSupport.xliff12sdl:
                _writer = new Xliff12SDLWriter();
                break;
            }
        }
        private IXliffReader GetXliffReader(Enumerators.XLIFFSupport support)
        {
            switch (support)
            {
            case Enumerators.XLIFFSupport.xliff12polyglot:
                return(new Xliff12PolyglotReader(_segmentBuilder));

            case Enumerators.XLIFFSupport.xliff12sdl:
                return(new Xliff12SdlReader(_segmentBuilder));

            default:
                return(null);
            }
        }
Example #4
0
        public void XliffReader_XLIFFSupportSniffer_ReturnsEqual(Enumerators.XLIFFSupport support)
        {
            // arrange
            var sniffer        = new XliffSniffer();
            var segmentBuilder = new SegmentBuilder();
            var xliffReader    = new XliffReder(sniffer, segmentBuilder);
            var testFile       = support == Enumerators.XLIFFSupport.xliff12polyglot
                                ? _testFilesUtil.GetSampleFilePath("Xliff12", "Polyglot", "DefaultSample.sdlxliff.xliff")
                                : _testFilesUtil.GetSampleFilePath("Xliff12", "xsi", "DefaultSample.sdlxliff.xliff");

            // act
            var reader = xliffReader.ReadXliff(testFile);

            // assert
            Assert.Equal(support, reader.Support);
        }
Example #5
0
        public void XliffReader_ReadLockedContent_ReturnsEqual(Enumerators.XLIFFSupport support)
        {
            // arrange
            var sniffer        = new XliffSniffer();
            var segmentBuilder = new SegmentBuilder();
            var xliffReader    = new XliffReder(sniffer, segmentBuilder);
            var testFile       = support == Enumerators.XLIFFSupport.xliff12polyglot
                                ? _testFilesUtil.GetSampleFilePath("Xliff12", "Polyglot", "LockedContentSample.sdlxliff.xliff")
                                : _testFilesUtil.GetSampleFilePath("Xliff12", "xsi", "LockedContentSample.sdlxliff.xliff");

            // act
            var reader             = xliffReader.ReadXliff(testFile);
            var segmentPair        = reader.Files[0].Body.TransUnits[0].SegmentPairs[0];
            var openElementLocked  = segmentPair.Target.Elements[1];
            var closeElementLocked = segmentPair.Target.Elements[9];

            // assert
            Assert.Equal(11, segmentPair.Target.Elements.Count);
            Assert.True(openElementLocked is ElementLocked openElement && openElement.Type == Element.TagType.OpeningTag);
            Assert.True(closeElementLocked is ElementLocked closeElement && closeElement.Type == Element.TagType.ClosingTag);
        }