Testing Code Fixes with RoslynTestKit
In Chapter 13, we saw how the RoslynTestKit
library helps your diagnostic analyzers flag code issues appropriately. In this chapter, we’ll revisit the library to verify our new code fix.
We will start by creating a new class in our test project named ToStringCodeFixTests
due to our common naming conventions.
This class will start by declaring a test fixture like it did with the analyzer:
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeFixes; using Microsoft.CodeAnalysis.Diagnostics; using RoslynTestKit; namespace Packt.Analyzers.Tests; public class ToStringCodeFixTests : CodeFixTestFixture { protected override string LanguageName => LanguageNames.CSharp; protected override CodeFixProvider CreateProvider() => new ToStringCodeFix(); protected override IReadOnlyCollection<DiagnosticAnalyzer> CreateAdditionalAnalyzers() => new[]...