private void CheckDifferenceBetweenReferenceAndOutput(string folder, bool useSpecialFileCompare, string markedContentFiles, Logger logger) { var folderComparer = new FolderComparer() { Logger = logger }; var specialFiles = new Dictionary <string, CompareMode>(); if (useSpecialFileCompare) { foreach (var item in SpecialFiles) { specialFiles.Add(item.Key, item.Value); } } if (markedContentFiles != null) { var contentFiles = markedContentFiles.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var fileName in contentFiles) { specialFiles.Add(fileName, CompareMode.MarkedContent); } } var comparence = folderComparer.CompareFolders(this.ReferenceFolder, this.OutputFolder, specialFiles); if (comparence.Any()) { var sb = new StringBuilder(); var lineCount = 0; foreach (var diff in comparence) { lineCount++; if (lineCount > MaxDiffLineCount) { sb.AppendLine("The diff log cut off because of max lines limit of " + MaxDiffLineCount + " lines."); break; } var diffReport = diff.ToString(); if (diffReport.Length > MaxDiffLineLength) { diffReport = diffReport.Remove(MaxDiffLineLength) + " ... the rest is removed due to too long"; } sb.AppendLine(diffReport); } folderComparer.LogDifferences("Project " + folder + " differences:", comparence); Assert.Fail(sb.ToString()); } }
public void Test(string folder, bool isToTranslate, bool useSpecialFileCompare) { GetPaths(folder); LogInfo("OutputTest Project " + folder); LogInfo("\tProjectFileName " + ProjectFileName); LogInfo("\tProjectFolder " + ProjectFolder); LogInfo("\tProjectFilePath " + ProjectFilePath); LogInfo("\tOutputFolder " + OutputFolder); LogInfo("\tReferenceFolder " + ReferenceFolder); var translator = new TranslatorRunner() { ProjectLocation = ProjectFilePath, BuildArguments = OutputTest.BuildArguments }; try { if (isToTranslate) { translator.Translate(); } else { translator.Build(); } } catch (Exception ex) { Assert.Fail("Could not {0} the project {1}. Exception occurred: {2}.", isToTranslate ? "translate" : "build", folder, ex.Message); } try { var comparence = FolderComparer.CompareFolders(this.ReferenceFolder, this.OutputFolder, useSpecialFileCompare ? SpecialFiles : null); if (comparence.Any()) { var sb = new StringBuilder(); foreach (var diff in comparence) { sb.AppendLine(diff.ToString()); } FolderComparer.LogDifferences("Project " + folder + " differences:", comparence); Assert.Fail(sb.ToString()); } } catch (Exception ex) { Assert.Fail("Could not compare the project {0} output. Exception occurred: {1}.", folder, ex.Message); } }
private void CheckDifferenceBetweenReferenceAndOutput(string folder, bool useSpecialFileCompare, string markedContentFiles, Logger logger) { var folderComparer = new FolderComparer() { Logger = logger }; var specialFiles = new Dictionary <string, CompareMode>(); if (useSpecialFileCompare) { foreach (var item in SpecialFiles) { specialFiles.Add(item.Key, item.Value); } } if (markedContentFiles != null) { var contentFiles = markedContentFiles.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var fileName in contentFiles) { specialFiles.Add(fileName, CompareMode.MarkedContent); } } var comparence = folderComparer.CompareFolders(this.ReferenceFolder, this.OutputFolder, specialFiles); if (comparence.Any()) { var sb = new StringBuilder(); foreach (var diff in comparence) { sb.AppendLine(diff.ToString()); } folderComparer.LogDifferences("Project " + folder + " differences:", comparence); Assert.Fail(sb.ToString()); } }
private void CheckDifferenceBetweenReferenceAndOutput(string folder, bool useSpecialFileCompare, Logger logger) { var folderComparer = new FolderComparer() { Logger = logger }; var comparence = folderComparer.CompareFolders(this.ReferenceFolder, this.OutputFolder, useSpecialFileCompare ? SpecialFiles : null); if (comparence.Any()) { var sb = new StringBuilder(); foreach (var diff in comparence) { sb.AppendLine(diff.ToString()); } folderComparer.LogDifferences("Project " + folder + " differences:", comparence); Assert.Fail(sb.ToString()); } }
public void Test(string folder, bool isToTranslate, bool useSpecialFileCompare) { var logDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); var logger = new Logger("Bridge.Test.Runner", true, new SimpleFileLoggerWriter(logDir), new ConsoleLoggerWriter()); GetPaths(folder); logger.Info("OutputTest Project " + folder); logger.Info("\tProjectFileName " + ProjectFileName); logger.Info("\tProjectFolder " + ProjectFolder); logger.Info("\tProjectFilePath " + ProjectFilePath); logger.Info("\tOutputFolder " + OutputFolder); logger.Info("\tReferenceFolder " + ReferenceFolder); var translator = new TranslatorRunner() { Logger = logger, ProjectLocation = ProjectFilePath, BuildArguments = OutputTest.BuildArguments }; try { if (isToTranslate) { translator.Translate(); } else { translator.Build(); } } catch (Exception ex) { Assert.Fail("Could not {0} the project {1}. Exception occurred: {2}.", isToTranslate ? "translate" : "build", folder, ex.Message); } try { var folderComparer = new FolderComparer() { Logger = logger }; var comparence = folderComparer.CompareFolders(this.ReferenceFolder, this.OutputFolder, useSpecialFileCompare ? SpecialFiles : null); if (comparence.Any()) { var sb = new StringBuilder(); foreach (var diff in comparence) { sb.AppendLine(diff.ToString()); } folderComparer.LogDifferences("Project " + folder + " differences:", comparence); Assert.Fail(sb.ToString()); } } catch (Exception ex) { var message = string.Format("Could not compare the project {0} output. Exception occurred: {1}.", folder, ex.Message); logger.Error(message); Assert.Fail(message); } }
public void Test(string folder, bool isToTranslate, bool useSpecialFileCompare) { var logger = new Logger("Bridge.Test.Runner", true, SimpleFileLoggerWriter.Instance, new ConsoleLoggerWriter()); GetPaths(folder); logger.Info("OutputTest Project " + folder); logger.Info("\tProjectFileName " + ProjectFileName); logger.Info("\tProjectFolder " + ProjectFolder); logger.Info("\tProjectFilePath " + ProjectFilePath); logger.Info("\tOutputFolder " + OutputFolder); logger.Info("\tReferenceFolder " + ReferenceFolder); var translator = new TranslatorRunner() { Logger = logger, ProjectLocation = ProjectFilePath, BuildArguments = OutputTest.BuildArguments }; try { if (isToTranslate) { translator.Translate(); } else { translator.Build(); } } catch (Exception ex) { Assert.Fail("Could not {0} the project {1}. Exception occurred: {2}.", isToTranslate ? "translate" : "build", folder, ex.Message); } try { var folderComparer = new FolderComparer() { Logger = logger }; var comparence = folderComparer.CompareFolders(this.ReferenceFolder, this.OutputFolder, useSpecialFileCompare ? SpecialFiles : null); if (comparence.Any()) { var sb = new StringBuilder(); foreach (var diff in comparence) { sb.AppendLine(diff.ToString()); } folderComparer.LogDifferences("Project " + folder + " differences:", comparence); Assert.Fail(sb.ToString()); } } catch (Exception ex) { var message = string.Format("Could not compare the project {0} output. Exception occurred: {1}.", folder, ex.Message); logger.Error(message); Assert.Fail(message); } }