private static void AssertCodeEqual(string originalSource, string expectedConversion, string actualConversion) { OurAssert.EqualIgnoringNewlines(expectedConversion, actualConversion, () => { StringBuilder sb = OurAssert.DescribeStringDiff(expectedConversion, actualConversion); sb.AppendLine(OurAssert.LineSplitter); sb.AppendLine("source:"); sb.AppendLine(originalSource); if (RecharacterizeByWritingExpectedOverActual) { TestFileRewriter.UpdateFiles(expectedConversion, actualConversion); } return(sb.ToString()); }); Assert.False(RecharacterizeByWritingExpectedOverActual, $"Test setup issue: Set {nameof(RecharacterizeByWritingExpectedOverActual)} to false after using it"); }
private void AssertFileEqual(Dictionary <string, ConversionResult> conversionResults, DirectoryInfo expectedResultDirectory, FileInfo expectedFile, string actualSolutionDir) { var convertedFilePath = expectedFile.FullName.Replace(expectedResultDirectory.FullName, actualSolutionDir); var fileDidNotNeedConversion = !conversionResults.ContainsKey(convertedFilePath) && File.Exists(convertedFilePath); if (fileDidNotNeedConversion) { return; } Assert.True(conversionResults.ContainsKey(convertedFilePath), expectedFile.Name + " is missing from the conversion result of [" + string.Join(",", conversionResults.Keys) + "]"); var expectedText = File.ReadAllText(expectedFile.FullName); var conversionResult = conversionResults[convertedFilePath]; var actualText = conversionResult.ConvertedCode ?? "" + conversionResult.GetExceptionsAsString() ?? ""; OurAssert.EqualIgnoringNewlines(expectedText, actualText); Assert.Equal(GetEncoding(expectedFile.FullName), GetEncoding(conversionResult)); }