public void ExecuteSqtppStandardIntegrationTest() { SqtppComparerOptions options = new SqtppComparerOptions { PathToSqtpp = Environment.PathToSqtpp, PathToWorkingDirectory = Environment.WorkingDirectory, OptionalArgumentsString = this.TestContext.DataRow["AdditionalOptions"].ToString() }; SqtppComparer sqtppComparer = new SqtppComparer(this.TestContext.DataRow["InputFile"].ToString(), this.TestContext.DataRow["ReferenceFile"].ToString(), options); ComparerResult comparerResult = sqtppComparer.Compare(); Assert.IsTrue(comparerResult.AreEqual, comparerResult.Message + "\r\n"); }
public ComparerResult Compare() { List <string> linesOfFirstFile = new List <string>(); List <string> linesOfSecondFile = new List <string>(); ComparerResult comparerResult = new ComparerResult(); try { LoadLinesFromFileIntoList(this.pathOfFirstFile, linesOfFirstFile); LoadLinesFromFileIntoList(this.pathOfSecondFile, linesOfSecondFile); } catch (Exception exception) { comparerResult.AreEqual = false; comparerResult.Message = exception.Message; return(comparerResult); } if (linesOfFirstFile.Count != linesOfSecondFile.Count) { comparerResult.AreEqual = false; comparerResult.Message = "Line count of Input and ReferenceOutput is not equal."; return(comparerResult); } for (int i = 0; i < linesOfFirstFile.Count; i++) { if (linesOfFirstFile[i] != linesOfSecondFile[i]) { comparerResult.AreEqual = false; comparerResult.Message = "Input-line '" + linesOfFirstFile[i] + "' is not equal to ReferenceOutput-line '" + linesOfSecondFile[i] + "'."; comparerResult.LineNumber = i; comparerResult.ColumnNumber = GetPositionOfFirstDifference(linesOfFirstFile[i], linesOfSecondFile[i]); return(comparerResult); } } comparerResult.Message = "Test passed"; comparerResult.AreEqual = true; return(comparerResult); }
/// <summary> /// Execute sqtpp and compare its output with the reference output file. /// </summary> /// <returns></returns> public ComparerResult Compare() { ExecuteSqtpp(); FileComparer fileComparer = new FileComparer(this.sqtppOutputFile, this.options.PathToWorkingDirectory + this.relativePathToReferenceFile); ComparerResult comparerResult = fileComparer.Compare(); if (!comparerResult.AreEqual) { string absoluteInputPath = System.IO.Path.GetFullPath(this.options.PathToWorkingDirectory + this.relativePathToInputFile); string absoluteOutputPath = System.IO.Path.GetFullPath(this.sqtppOutputFile); string absoluteReferencePath = System.IO.Path.GetFullPath(this.options.PathToWorkingDirectory + this.relativePathToReferenceFile); Trace.WriteLine("Test failed for "); Trace.Write('\t'); Trace.WriteLine(absoluteInputPath); Trace.WriteLine("when comparing to "); Trace.Write('\t'); Trace.WriteLine(absoluteOutputPath); Trace.WriteLine("with reference output in"); Trace.Write('\t'); Trace.WriteLine(absoluteReferencePath); Trace.WriteLine("Error message:"); Trace.Write('\t'); Trace.WriteLine(comparerResult.Message); Trace.WriteLine(""); string identifier = this.relativePathToInputFile + " (" + comparerResult.LineNumber + "," + comparerResult.ColumnNumber + "): "; comparerResult.Message = identifier + comparerResult.Message; } else { System.IO.File.Delete(this.sqtppOutputFile); } return(comparerResult); }