private static void WriteUnitTestGroup(UnitTestGroupViewModel group, DocX doc) { Paragraph p; p = doc.InsertParagraph(); p.StyleName = "Heading1"; p.InsertText(group.TestId); p = doc.InsertParagraph(); p.StyleName = "Normal"; p.Italic(); p.Append(string.Format("{0}", group.ParentPath)); foreach (UnitTestObjectViewModel item in group.UnitTestObjects) { if (item is UnitTestGroupViewModel) { DocXExporter.WriteUnitTestGroup(item as UnitTestGroupViewModel, doc); } else if (item is UnitTestViewModel) { DocXExporter.WriteUnitTest(item as UnitTestViewModel, doc); } else { throw new ArgumentException("Unknown unit test object"); } doc.InsertSectionPageBreak(); } }
public static void ExportUnitTestAsDocX(string fileName, UnitTestFileViewModel unitTestFile) { DocX doc = DocX.Create(fileName); doc.AddFooters(); doc.Footers.even.InsertParagraph(unitTestFile.FileName); doc.Footers.odd.InsertParagraph(unitTestFile.FileName); Paragraph p = doc.InsertParagraph(); p = doc.InsertParagraph(); p.StyleName = "Title"; p.InsertText("Acma Unit Test Definitions"); doc.InsertSectionPageBreak(); foreach (var unitTest in unitTestFile.UnitTestObjects) { if (unitTest is UnitTestGroupViewModel) { DocXExporter.WriteUnitTestGroup(unitTest as UnitTestGroupViewModel, doc); } else if (unitTest is UnitTestViewModel) { DocXExporter.WriteUnitTest(unitTest as UnitTestViewModel, doc); } else { throw new ArgumentException("Unknown unit test object"); } doc.InsertSectionPageBreak(); } doc.Save(); }