private async Task RunTest([CallerMemberName] string testMethod = "")
    {
        // Arrange
        var project            = GetProject(testMethod);
        var controllerDocument = project.DocumentIds[0];
        var expectedOutput     = Read(testMethod + ".Output");

        // Act
        var diagnostics = await AnalyzerRunner.GetDiagnosticsAsync(project);

        Assert.NotEmpty(diagnostics);
        var actualOutput = await CodeFixRunner.ApplyCodeFixAsync(
            new ApiActionsDoNotRequireExplicitModelValidationCheckCodeFixProvider(),
            project.GetDocument(controllerDocument),
            diagnostics[0]);

        Assert.Equal(expectedOutput, actualOutput, ignoreLineEndingDifferences: true);
    }
Ejemplo n.º 2
0
        private async Task RunTest([CallerMemberName] string testMethod = "")
        {
            // Arrange
            var project            = GetProject(testMethod);
            var controllerDocument = project.DocumentIds[0];

            var expectedOutput = Read(testMethod + ".Output");

            // Act
            var diagnostics = await AnalyzerRunner.GetDiagnosticsAsync(project);

            var actualOutput = await CodeFixRunner.ApplyCodeFixAsync(
                new AddResponseTypeAttributeCodeFixProvider(),
                project.GetDocument(controllerDocument),
                diagnostics[0]);

            Assert.Equal(expectedOutput, actualOutput, ignoreLineEndingDifferences: true);
        }