CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
AsynchronousBusinessRuleInheritingFromBusinessRuleAnalyzerTests.cs
Go to the documentation of this file.
1using System;
2using System.Threading.Tasks;
3using Microsoft.CodeAnalysis;
4using Microsoft.VisualStudio.TestTools.UnitTesting;
5
7{
8 [TestClass]
10 {
11 [TestMethod]
13 {
15 var diagnostics = analyzer.SupportedDiagnostics;
16 Assert.AreEqual(1, diagnostics.Length);
17
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));
29 Assert.AreEqual(HelpUrlBuilder.Build(Constants.AnalyzerIdentifiers.AsynchronousBusinessRuleInheritance, nameof(AsynchronousBusinessRuleInheritingFromBusinessRuleAnalyzer)),
30 diagnostic.HelpLinkUri,
31 nameof(DiagnosticDescriptor.HelpLinkUri));
32 }
33
34 [TestMethod]
36 {
37 var code = "public class A { }";
38 await TestHelpers.RunAnalysisAsync<AsynchronousBusinessRuleInheritingFromBusinessRuleAnalyzer>(
39 code, Array.Empty<string>());
40 }
41
42 [TestMethod]
44 {
45 var code =
46@"using Csla.Rules;
47
48public class A : BusinessRule { }";
49 await TestHelpers.RunAnalysisAsync<AsynchronousBusinessRuleInheritingFromBusinessRuleAnalyzer>(
50 code, Array.Empty<string>());
51 }
52
53 [TestMethod]
55 {
56 var code =
57@"using Csla.Rules;
58
59public class A : BusinessRule
60{
61 protected override void Execute(IRuleContext context)
62 {
63 base.Execute(context);
64 }
65}";
66 await TestHelpers.RunAnalysisAsync<AsynchronousBusinessRuleInheritingFromBusinessRuleAnalyzer>(
67 code, Array.Empty<string>());
68 }
69
70 [TestMethod]
72 {
73 var code =
74@"using Csla.Rules;
75using System.Threading.Tasks;
76
77public class A : BusinessRule
78{
79 protected override async void Execute(IRuleContext context)
80 {
81 await Task.Yield();
82 base.Execute(context);
83 }
84}";
85 await TestHelpers.RunAnalysisAsync<AsynchronousBusinessRuleInheritingFromBusinessRuleAnalyzer>(
86 code, new[] { Constants.AnalyzerIdentifiers.AsynchronousBusinessRuleInheritance });
87 }
88 }
89}