/// <summary>
        /// Lines that already have comments aren't automatically tested, so if a line changes order in a conversion, just add a comment to that line.
        /// If there's a comment conversion issue, set the optional hasLineCommentConversionIssue to true
        /// </summary>
        private async Task AssertLineCommentsConvertedInSameOrderAsync <TLanguageConversion>(string source, TextConversionOptions conversion, string singleLineCommentStart, Func <string, bool> lineCanHaveComment) where TLanguageConversion : ILanguageConversion, new()
        {
            var(sourceLinesWithComments, lineNumbersAdded) = AddLineNumberComments(source, singleLineCommentStart, AutoTestCommentPrefix, lineCanHaveComment);
            string sourceWithComments = string.Join(Environment.NewLine, sourceLinesWithComments);
            var    convertedCode      = await ConvertAsync <TLanguageConversion>(sourceWithComments, conversion);

            var convertedCommentLineNumbers = convertedCode.Split(new[] { AutoTestCommentPrefix }, StringSplitOptions.None)
                                              .Skip(1).Select(afterPrefix => afterPrefix.Split('\n')[0].TrimEnd()).ToList();
            var missingSourceLineNumbers = lineNumbersAdded.Except(convertedCommentLineNumbers);

            if (missingSourceLineNumbers.Any())
            {
                Assert.False(true, "Comments not converted from source lines: " + string.Join(", ", missingSourceLineNumbers) + GetSourceAndConverted(sourceWithComments, convertedCode));
            }
            OurAssert.Equal(string.Join(", ", lineNumbersAdded), string.Join(", ", convertedCommentLineNumbers), () => GetSourceAndConverted(sourceWithComments, convertedCode));
        }
 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));
        }