public void FindTableTitleInSinglePageWarnning_WritesCorrectCommentsInDoc() { //Arrange var fileName = @"..\..\..\TestFiles\FindTableTitleInSinglePageWarnning.doc"; var log = _fixture.log; string xml = DataInitializer.AIReportCheckXml; var config = XDocument.Parse(xml); var ai = new AsposeAIReportCheck(fileName, log.Object, config); //Act ai.FindTableTitleInSinglePageWarnning(); using (MemoryStream dstStream = new MemoryStream()) { ai._doc.Save(dstStream, SaveFormat.Doc); } Comment docComment = (Comment)ai._doc.GetChild(NodeType.Comment, 0, true); NodeCollection allComments = ai._doc.GetChildNodes(NodeType.Comment, true); //Assert Assert.Single(allComments); Assert.Contains("表格标题单独位于某1页", docComment.GetText()); }
public void FindPictureTitleSequenceNumberError_WritesCorrectCommentsInDoc() { //Arrange var fileName = @"..\..\..\TestFiles\FindPictureTitleSequenceNumberError.doc"; var log = _fixture.log; string xml = DataInitializer.AIReportCheckXml; var config = XDocument.Parse(xml); var ai = new AsposeAIReportCheck(fileName, log.Object, config); //Act ai.FindPictureTitleSequenceNumberError(); using (MemoryStream dstStream = new MemoryStream()) { ai._doc.Save(dstStream, SaveFormat.Doc); } Comment docComment = (Comment)ai._doc.GetChild(NodeType.Comment, 0, true); NodeCollection allComments = ai._doc.GetChildNodes(NodeType.Comment, true); //Assert Assert.Equal(2, allComments.Count); Assert.Contains("本图片序号应为3-8", docComment.GetText()); }
public void FindStrainOrDispError_WritesCorrectCommentsInDoc() { //Arrange var fileName = @"..\..\..\TestFiles\FindStrainOrDispError.doc"; var log = _fixture.log; string xml = @"<?xml version=""1.0"" encoding=""utf - 8"" ?> <configuration> <FindStrainOrDispError row1=""0"" col1=""0"" row2 =""1"" col2 =""1"" charactorString =""测点号"" > <Strain charactorString = ""总应变"" /> <Disp charactorString = ""总变形"" /> </FindStrainOrDispError > </configuration >"; var config = XDocument.Parse(xml); var ai = new AsposeAIReportCheck(fileName, log.Object, config); //Act ai.FindStrainOrDispError(); using (MemoryStream dstStream = new MemoryStream()) { ai._doc.Save(dstStream, SaveFormat.Doc); } Comment docComment = (Comment)ai._doc.GetChild(NodeType.Comment, 0, true); NodeCollection allComments = ai._doc.GetChildNodes(NodeType.Comment, true); //Assert Assert.Equal(6, allComments.Count); Assert.True(docComment.GetText().IndexOf("计算错误") >= 0); }
public void FindStrainOrDispContextWarnning_WritesCorrectCommentsInDoc() { //Arrange var fileName = @"..\..\..\TestFiles\FindStrainOrDispContextWarnning.doc"; var log = _fixture.log; string xml = DataInitializer.AIReportCheckXml; var config = XDocument.Parse(xml); var ai = new AsposeAIReportCheck(fileName, log.Object, config); //Act ai.FindStrainOrDispContextWarnning(); using (MemoryStream dstStream = new MemoryStream()) { ai._doc.Save(dstStream, SaveFormat.Doc); } Comment docComment1 = (Comment)ai._doc.GetChild(NodeType.Comment, 0, true); Comment docComment2 = (Comment)ai._doc.GetChild(NodeType.Comment, 1, true); NodeCollection allComments = ai._doc.GetChildNodes(NodeType.Comment, true); //Assert Assert.Equal(2, allComments.Count); Assert.Contains("校验系数在0.33~0.36之间", docComment1.GetText()); Assert.Contains("校验系数在0.35~0.44之间", docComment2.GetText()); }
public void FindPictureTitleSequenceNumberError_ReturnsCorrectCountOfReportError() { //Arrange var fileName = @"..\..\..\TestFiles\FindPictureTitleSequenceNumberError.doc"; var log = _fixture.log; string xml = DataInitializer.AIReportCheckXml; var config = XDocument.Parse(xml); var ai = new AsposeAIReportCheck(fileName, log.Object, config); //Act ai.FindPictureTitleSequenceNumberError(); //Assert Assert.Equal(2, ai.reportError.Count); Assert.Equal(ErrorNumber.Description, ai.reportError[0].No); }
public void FindTableTitleInSinglePageWarnning_ReturnsCorrectCountOfReportError() { //Arrange var fileName = @"..\..\..\TestFiles\FindTableTitleInSinglePageWarnning.doc"; var log = _fixture.log; string xml = DataInitializer.AIReportCheckXml; var config = XDocument.Parse(xml); var ai = new AsposeAIReportCheck(fileName, log.Object, config); //Act ai.FindTableTitleInSinglePageWarnning(); //Assert Assert.Single(ai.reportWarnning); Assert.Equal(WarnningNumber.FormatProblem, ai.reportWarnning[0].No); }
static void Main(string[] args) { System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); var kernel = new StandardKernel(new Infrastructure.NinjectDependencyResolver()); var a = kernel.Get <IAIReportCheck>(); string fileName = "glz.doc"; var doc = new Document(fileName); var ai = new AsposeAIReportCheck(doc); //获取word文档中的第一个表格 //var table0 = doc.GetChildNodes(NodeType.Table, true)[1] as Table; //var table0 = ai.GetOverViewTable(); //var cell = table0.Rows[4].Cells[1]; //string cbfbm = cell.GetText(); //string[] splitArray = cbfbm.Split('\r'); ////用GetText()的方法来获取cell中的值 //foreach (var s in splitArray) //{ // s.Replace("\a", ""); // s.Replace("\r", ""); // Console.WriteLine(s); // Levenshtein(@"《城市桥梁设计规范》(CJJ 11-2011)", @s); //}; ai.CheckReport(); //if(ai.reportError!=null) //{ // foreach(var e in ai.reportError) // { // Console.WriteLine(e.No); // Console.WriteLine(e.Name); // } //} }
public void FindStrainOrDispContextWarnning_ReturnsCorrectCountOfReportWarnning() { //Arrange var fileName = @"..\..\..\TestFiles\FindStrainOrDispContextWarnning.doc"; var log = _fixture.log; string xml = DataInitializer.AIReportCheckXml; var config = XDocument.Parse(xml); var ai = new AsposeAIReportCheck(fileName, log.Object, config); //Act ai.FindStrainOrDispContextWarnning(); //Assert Assert.Equal(2, ai.reportWarnning.Count); Assert.Equal(WarnningNumber.NotFoundInfo, ai.reportWarnning[0].No); Assert.Contains("校验系数在0.33~0.36之间", ai.reportWarnning[0].Description); //概述表格中统计数据错误 Assert.Equal(WarnningNumber.NotFoundInfo, ai.reportWarnning[1].No); Assert.Contains("校验系数在0.35~0.44之间", ai.reportWarnning[1].Description); //汇总表格附近统计数据错误 }
public void FindStrainOrDispError_ReturnsCorrectCountOfReportError() { //Arrange var fileName = @"..\..\..\TestFiles\FindStrainOrDispError.doc"; var log = _fixture.log; string xml = @"<?xml version=""1.0"" encoding=""utf - 8"" ?> <configuration> <FindStrainOrDispError row1=""0"" col1=""0"" row2 =""1"" col2 =""1"" charactorString =""测点号"" > <Strain charactorString = ""总应变"" /> <Disp charactorString = ""总变形"" /> </FindStrainOrDispError > </configuration >"; var config = XDocument.Parse(xml); var ai = new AsposeAIReportCheck(fileName, log.Object, config); //Act ai.FindStrainOrDispError(); //Assert Assert.Equal(6, ai.reportError.Count); Assert.Equal(ErrorNumber.Calc, ai.reportError[0].No); }