コード例 #1
0
        public void MergeJson2Docx_TranslatedStringsMatchJsonStringCountTest()
        {
            var resultStrings = new List <string>();

            resultStrings.Add("Result string 1");
            resultStrings.Add("Result string 2");
            resultStrings.Add("Result string 3");
            resultStrings.Add("Result string 4");
            resultStrings.Add("Result string 5");

            var mockTextMerger = new Mock <IDocxTextMerger>();

            mockTextMerger.Setup(tb => tb.Merge(It.IsAny <JsonConversionData>(), It.IsAny <DocxConversionData>(), It.IsAny <bool>()))
            .Returns(resultStrings);

            var sut = new MergeService(mockTextMerger.Object);

            var jsonFileData = new JsonConversionData(fullJsonTestFilePath)
            {
                TotalStrings2Translate = 5
            };

            var docxFileData = new DocxConversionData(fullDocxTestFilePath)
            {
                TotalStrings2Translate = 5
            };

            var result = sut.MergeJson2Docx(jsonFileData, docxFileData);

            Assert.AreEqual(result, "Success");
        }
コード例 #2
0
        public void MergeJson2Docx_TextBuilderExceptionHandledTest()
        {
            var exceptionMessage = "This is the exception message.";
            var mockTextMerger   = new Mock <IDocxTextMerger>();

            mockTextMerger.Setup(tm => tm.Merge(It.IsAny <JsonConversionData>(), It.IsAny <DocxConversionData>(), It.IsAny <bool>()))
            .Throws(new ArgumentNullException("docxFileData", exceptionMessage));

            var sut = new MergeService(mockTextMerger.Object);

            var jsonFileData = new JsonConversionData(fullJsonTestFilePath);
            var docxFileData = new DocxConversionData(fullDocxTestFilePath);

            var result = sut.MergeJson2Docx(jsonFileData, docxFileData);

            Assert.AreEqual(0, result.IndexOf(exceptionMessage));
        }
コード例 #3
0
        public void TestMergeJson2Docx()
        {
            //make sure test files exist
            TestingJsonFileTest();
            TestingTestDocxFile();

            JsonConversionData jsonFileData = docxJsonService.BuildJsonConversionData(FullJsonTestFilePath);
            DocxConversionData docxFileData = docxFileService.CreateCleanedCopy(FullDocxTestFilePath, false);

            var    mergeService    = new MergeService(new DocxTextMerger(new DocumentTextRunExtractionService()));
            string ResponseMessage = mergeService.MergeJson2Docx(jsonFileData, docxFileData);

            Assert.AreEqual(ResponseMessage, "Success");
            Assert.IsTrue(File.Exists(docxFileData.FullPath));

            //Clean Up file that was created
            File.Delete(docxFileData.FullPath);
        }
コード例 #4
0
        public void MergeJson2Docx_EnsureStringCountsMatchTest()
        {
            var mockTextMerger = new Mock <IDocxTextMerger>();
            var sut            = new MergeService(mockTextMerger.Object);

            var jsonFileData = new JsonConversionData(fullJsonTestFilePath)
            {
                TotalStrings2Translate = 5
            };

            var docxFileData = new DocxConversionData(fullDocxTestFilePath)
            {
                TotalStrings2Translate = 3
            };

            var result = sut.MergeJson2Docx(jsonFileData, docxFileData);

            Assert.AreEqual(result.IndexOf("MERGE FAILED"), 0);
        }