2using Microsoft.VisualStudio.TestTools.UnitTesting;
5using System.Threading.Tasks;
16 var diagnostics = analyzer.SupportedDiagnostics;
17 Assert.AreEqual(2, diagnostics.Length);
19 var diagnostic = diagnostics.Single(_ => _.Id == Constants.AnalyzerIdentifiers.IsOperationMethodPublic);
20 Assert.AreEqual(IsOperationMethodPublicAnalyzerConstants.Title, diagnostic.Title.ToString(),
21 nameof(DiagnosticDescriptor.Title));
22 Assert.AreEqual(IsOperationMethodPublicAnalyzerConstants.Message, diagnostic.MessageFormat.ToString(),
23 nameof(DiagnosticDescriptor.MessageFormat));
24 Assert.AreEqual(Constants.Categories.Design, diagnostic.Category,
25 nameof(DiagnosticDescriptor.Category));
26 Assert.AreEqual(DiagnosticSeverity.Warning, diagnostic.DefaultSeverity,
27 nameof(DiagnosticDescriptor.DefaultSeverity));
29 diagnostic.HelpLinkUri,
30 nameof(DiagnosticDescriptor.HelpLinkUri));
32 var diagnosticForInterface = diagnostics.Single(_ => _.Id == Constants.AnalyzerIdentifiers.IsOperationMethodPublicForInterface);
33 Assert.AreEqual(IsOperationMethodPublicAnalyzerConstants.Title, diagnosticForInterface.Title.ToString(),
34 nameof(DiagnosticDescriptor.Title));
35 Assert.AreEqual(IsOperationMethodPublicAnalyzerConstants.Message, diagnosticForInterface.MessageFormat.ToString(),
36 nameof(DiagnosticDescriptor.MessageFormat));
37 Assert.AreEqual(Constants.Categories.Design, diagnosticForInterface.Category,
38 nameof(DiagnosticDescriptor.Category));
39 Assert.AreEqual(DiagnosticSeverity.Warning, diagnosticForInterface.DefaultSeverity,
40 nameof(DiagnosticDescriptor.DefaultSeverity));
42 diagnosticForInterface.HelpLinkUri,
43 nameof(DiagnosticDescriptor.HelpLinkUri));
53 public void Fetch() { }
56 code, Array.Empty<
string>());
67public class A : BusinessBase<A>
69 public void AMethod() { }
72 code, Array.Empty<
string>());
83public class A : BusinessBase<A>
85 private void DataPortal_Fetch() { }
88 code, Array.Empty<
string>());
99public class A : BusinessBase<A>
102 public void Fetch() { }
105 new[] { Constants.AnalyzerIdentifiers.IsOperationMethodPublic },
106 diagnostics => Assert.AreEqual(
false.ToString(), diagnostics[0].Properties[IsOperationMethodPublicAnalyzerConstants.IsSealed]));
117public sealed class A : BusinessBase<A>
120 public void Fetch() { }
123 new[] { Constants.AnalyzerIdentifiers.IsOperationMethodPublic },
124 diagnostics => Assert.AreEqual(
true.ToString(), diagnostics[0].Properties[IsOperationMethodPublicAnalyzerConstants.IsSealed]));
141 new[] { Constants.AnalyzerIdentifiers.IsOperationMethodPublicForInterface });
async Task AnalyzeWhenTypeIsStereotypeAndMethodIsADataPortalOperationThatIsPublicAndClassIsSealed()
void VerifySupportedDiagnostics()
async Task AnalyzeWhenTypeIsStereotypeAndMethodIsADataPortalOperationThatIsPublicAndClassIsNotSealed()
async Task AnalyzeWhenTypeIsNotStereotype()
async Task AnalyzeWhenTypeIsStereotypeAndMethodIsADataPortalOperationThatIsNotPublic()
async Task AnalyzeWhenTypeIsStereotypeAndMethodIsNotADataPortalOperation()
async Task AnalyzeWhenTypeIsStereotypeAndMethodIsADataPortalOperationThatIsPublicAndTypeIsInterface()