string OutputWorkSheet(string workBookName, ITabularPage sheet) { var sheetConverter = new ExcelToCode(new CodeNameToExcelNameConverter(assertionClassPrefix)); sheetConverter.AddVisitor(givenClassRecorder); var generatedTest = sheetConverter.GenerateCSharpTestCode( usings, sheet, projectRootNamespace, workBookName); generatedTest.Errors.ToList().ForEach(error => logger.LogWorkbookError(workBookName, sheet.Name, error)); generatedTest.Warnings.ToList().ForEach(warning => logger.LogWarning(workBookName, sheet.Name, warning)); generatedTest.IssuesPreventingRoundTrip.ToList().ForEach(issue => logger.LogIssuePreventingRoundTrip(workBookName, sheet.Name, issue)); return(generatedTest.Code); }
private static string OutputWorkSheet(string outputFolder, IEnumerable <string> usings, string assertionClassPrefix, string workBookName, ITabularPage sheet, string projectRootNamespace) { var sheetConverter = new ExcelToCode(new CodeNameToExcelNameConverter(assertionClassPrefix)); var projectRelativePath = Path.Combine(workBookName, sheet.Name + ".cs"); var outputPath = Path.Combine(outputFolder, projectRelativePath); Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); using (var outputFile = new StreamWriter(outputPath)) { try { outputFile.Write(sheetConverter.GenerateCSharpTestCode(usings, assertionClassPrefix, sheet, projectRootNamespace, workBookName)); } catch (Exception ex) { outputFile.Write(string.Format("Error creating c# from Excel: {0}", ex.Message)); } } return(projectRelativePath); }