Exemplo n.º 1
0
 private static void AssertCodeEqual(string originalSource, string expectedConversion, string actualConversion)
 {
     OurAssert.StringsEqualIgnoringNewlines(expectedConversion, actualConversion, () =>
     {
         StringBuilder sb = OurAssert.DescribeStringDiff(expectedConversion, actualConversion);
         sb.AppendLine();
         sb.AppendLine("source:");
         sb.AppendLine(originalSource);
         if (WriteNewCharacterization)
         {
             TestFileRewriter.UpdateFiles(expectedConversion, actualConversion);
         }
         return(sb.ToString());
     });
     Assert.False(WriteNewCharacterization, $"Test setup issue: Set {nameof(WriteNewCharacterization)} to false after using it");
 }
Exemplo n.º 2
0
        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.StringsEqualIgnoringNewlines(expectedText, actualText);
            Assert.Equal(GetEncoding(expectedFile.FullName), GetEncoding(conversionResult));
        }