diff --git a/DocGpt.Test/CodeFixTests.cs b/DocGpt.Test/CodeFixTests.cs index 02e808b..71f6fa8 100644 --- a/DocGpt.Test/CodeFixTests.cs +++ b/DocGpt.Test/CodeFixTests.cs @@ -14,7 +14,7 @@ [TestClass] public class CodeFixTests { - public static TestContext Context { get; private set; } + public TestContext Context { get; set; } [ClassInitialize] public static void ClassInit(TestContext context) @@ -23,7 +23,7 @@ public static void ClassInit(TestContext context) DocGptOptions.Instance.ApiKey = "foo"; DocGptOptions.Instance.ModelDeploymentName = "foo"; - Context = context; + //Context = context; } /// @@ -71,5 +71,65 @@ class MyClass Microsoft.CodeAnalysis.Testing.DiagnosticResult expected = VerifyCS.Diagnostic(DocGptAnalyzer.Rule).WithSpan(14, 31, 14, 38).WithArguments("FieldDeclaration", "MyConst"); await VerifyCS.VerifyCodeFixAsync(test, expected, fixd); } + + /// + /// Analyzers the throws class decl. + /// + /// A Task. + [TestMethod] + public async Task CodeFix_DGPT001_Override() + { + string test = @" +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Diagnostics; + +namespace ConsoleApplication1 +{ + /// + class MyClass + { + /// Foo + protected virtual bool DoSomething() => true; + } + + /// + class MyDerivedClass : MyClass + { + protected override bool DoSomething() => false; + } +}"; + + string fixd = @" +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Diagnostics; + +namespace ConsoleApplication1 +{ + /// + class MyClass + { + /// Foo + protected virtual bool DoSomething() => true; + } + + /// + class MyDerivedClass : MyClass + { + /// + protected override bool DoSomething() => false; + } +}"; + + Microsoft.CodeAnalysis.Testing.DiagnosticResult expected = VerifyCS.Diagnostic(DocGptAnalyzer.Rule).WithSpan(21, 33, 21, 44).WithArguments("MethodDeclaration", "DoSomething"); + await VerifyCS.VerifyCodeFixAsync(test, expected, fixd); + } } }