зеркало из https://github.com/dotnet/razor.git
Improve integration tests
This commit is contained in:
Родитель
5bc34898ac
Коммит
e5160528c3
|
@ -24,27 +24,11 @@ public class FormatDocumentTests(ITestOutputHelper testOutputHelper) : AbstractR
|
|||
// If you want to generate the "after" state simple run the test without
|
||||
// creating the expected file, and it will be generated for you.
|
||||
//
|
||||
// Things that aren't (yet?) supported:
|
||||
// * Formatting must change the input state or the test will hang
|
||||
// ie. these tests cannot be used for pure validation
|
||||
// * Test input is always placed in a .razor file, so .cshtml specific
|
||||
// quirks can't be validated
|
||||
//
|
||||
// You'll just have to write tests for those ones :P
|
||||
// NOTE: Formatting must change the input state or the test will hang
|
||||
// ie. these tests cannot be used for pure validation
|
||||
|
||||
[IdeTheory]
|
||||
[InlineData("BadlyFormattedCounter.razor")]
|
||||
[InlineData("FormatCommentWithKeyword.cshtml")]
|
||||
[InlineData("FormatDocument.cshtml")]
|
||||
[InlineData("FormatDocumentAfterEdit.cshtml")]
|
||||
[InlineData("FormatDocumentWithTextAreaAttributes.cshtml")]
|
||||
[InlineData("FormatIfBlockInsideForBlock.cshtml")]
|
||||
[InlineData("FormatOnPaste.cshtml")]
|
||||
[InlineData("FormatOnPasteContainedLanguageCode.cshtml")]
|
||||
[InlineData("FormatSelection.cshtml")]
|
||||
[InlineData("FormatSelectionStartingWithContainedLanguageCode.cshtml")]
|
||||
[InlineData("FormatSwitchCaseBlock.cshtml")]
|
||||
[InlineData("RazorInCssClassAttribute.cshtml")]
|
||||
[MemberData(nameof(GetFormattingTestResourceNames))]
|
||||
public async Task FormattingDocument(string testFileName)
|
||||
{
|
||||
var inputResourceName = GetResourceName(testFileName, "Input");
|
||||
|
@ -92,8 +76,11 @@ public class FormatDocumentTests(ITestOutputHelper testOutputHelper) : AbstractR
|
|||
AssertEx.EqualOrDiff(expected, actual);
|
||||
}
|
||||
|
||||
private static string GetResourceBaseName()
|
||||
=> $"{typeof(FormatDocumentTests).Namespace}.Formatting.TestFiles";
|
||||
|
||||
private static string GetResourceName(string name, string suffix)
|
||||
=> $"{typeof(FormatDocumentTests).Namespace}.Formatting.TestFiles.{suffix}.{name}";
|
||||
=> $"{GetResourceBaseName()}.{suffix}.{name}";
|
||||
|
||||
private static bool TryGetResource(string name, [NotNullWhen(true)] out string? value)
|
||||
{
|
||||
|
@ -112,4 +99,21 @@ public class FormatDocumentTests(ITestOutputHelper testOutputHelper) : AbstractR
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static TheoryData<string> GetFormattingTestResourceNames()
|
||||
{
|
||||
var baseName = $"{GetResourceBaseName()}.Input.";
|
||||
var data = new TheoryData<string>();
|
||||
var names = typeof(FormatDocumentTests).Assembly.GetManifestResourceNames();
|
||||
|
||||
foreach (var name in names)
|
||||
{
|
||||
if (name.StartsWith(baseName))
|
||||
{
|
||||
data.Add(Path.GetFileName(name)[baseName.Length..]);
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче