2using System.Threading.Tasks;
4using Microsoft.VisualStudio.TestTools.UnitTesting;
15 var diagnostics = analyzer.SupportedDiagnostics;
16 Assert.AreEqual(1, diagnostics.Length);
18 var diagnostic = diagnostics[0];
19 Assert.AreEqual(Constants.AnalyzerIdentifiers.AsynchronousBusinessRuleInheritance, diagnostic.Id,
20 nameof(DiagnosticDescriptor.Id));
21 Assert.AreEqual(AsynchronousBusinessRuleInheritingFromBusinessRuleAnalyzerConstants.Title, diagnostic.Title.ToString(),
22 nameof(DiagnosticDescriptor.Title));
23 Assert.AreEqual(AsynchronousBusinessRuleInheritingFromBusinessRuleAnalyzerConstants.Message, diagnostic.MessageFormat.ToString(),
24 nameof(DiagnosticDescriptor.MessageFormat));
25 Assert.AreEqual(Constants.Categories.Usage, diagnostic.Category,
26 nameof(DiagnosticDescriptor.Category));
27 Assert.AreEqual(DiagnosticSeverity.Error, diagnostic.DefaultSeverity,
28 nameof(DiagnosticDescriptor.DefaultSeverity));
30 diagnostic.HelpLinkUri,
31 nameof(DiagnosticDescriptor.HelpLinkUri));
37 var code =
"public class A { }";
39 code, Array.Empty<
string>());
48public class A : BusinessRule { }";
50 code, Array.Empty<
string>());
59public class A : BusinessRule
61 protected override void Execute(IRuleContext context)
63 base.Execute(context);
67 code, Array.Empty<
string>());
75using System.Threading.Tasks;
77public class A : BusinessRule
79 protected override async void Execute(IRuleContext context)
82 base.Execute(context);
86 code,
new[] { Constants.AnalyzerIdentifiers.AsynchronousBusinessRuleInheritance });
void VerifySupportedDiagnostics()
async Task AnalyzeWhenClassIsABusinessRuleAndOverridesExecuteAndIsAsync()
async Task AnalyzeWhenClassIsABusinessRuleButDoesNotOverrideExecute()
async Task AnalyzeWhenClassIsNotABusinessRule()
async Task AnalyzeWhenClassIsABusinessRuleAndOverridesExecuteAndIsNotAsync()