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.
DoesChildOperationHaveRunLocalAnalyzerTests.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 {
14 var analyzer = new DoesChildOperationHaveRunLocalAnalyzer();
15 var diagnostics = analyzer.SupportedDiagnostics;
16 Assert.AreEqual(1, diagnostics.Length);
17
18 var diagnostic = diagnostics[0];
19 Assert.AreEqual(Constants.AnalyzerIdentifiers.DoesChildOperationHaveRunLocal, diagnostic.Id,
20 nameof(DiagnosticDescriptor.Id));
21 Assert.AreEqual(DoesChildOperationHaveRunLocalAnalyzerConstants.Title, diagnostic.Title.ToString(),
22 nameof(DiagnosticDescriptor.Title));
23 Assert.AreEqual(DoesChildOperationHaveRunLocalAnalyzerConstants.Message, diagnostic.MessageFormat.ToString(),
24 nameof(DiagnosticDescriptor.MessageFormat));
25 Assert.AreEqual(Constants.Categories.Usage, diagnostic.Category,
26 nameof(DiagnosticDescriptor.Category));
27 Assert.AreEqual(DiagnosticSeverity.Warning, diagnostic.DefaultSeverity,
28 nameof(DiagnosticDescriptor.DefaultSeverity));
29 Assert.AreEqual(HelpUrlBuilder.Build(Constants.AnalyzerIdentifiers.DoesChildOperationHaveRunLocal, nameof(DoesChildOperationHaveRunLocalAnalyzer)),
30 diagnostic.HelpLinkUri,
31 nameof(DiagnosticDescriptor.HelpLinkUri));
32 }
33
34 [TestMethod]
36 {
37 var code = "public class A { }";
38 await TestHelpers.RunAnalysisAsync<DoesChildOperationHaveRunLocalAnalyzer>(
39 code, Array.Empty<string>());
40 }
41
42 [TestMethod]
44 {
45 var code =
46@"using Csla;
47
48public class A : BusinessBase<A>
49{
50 [RunLocal]
51 [Fetch]
52 private void Fetch() { }
53}";
54 await TestHelpers.RunAnalysisAsync<DoesChildOperationHaveRunLocalAnalyzer>(
55 code, Array.Empty<string>());
56 }
57
58 [TestMethod]
60 {
61 var code =
62@"using Csla;
63
64public class A : BusinessBase<A>
65{
66 [FetchChild]
67 private void FetchChild() { }
68}";
69 await TestHelpers.RunAnalysisAsync<DoesChildOperationHaveRunLocalAnalyzer>(
70 code, Array.Empty<string>());
71 }
72
73 [TestMethod]
75 {
76 var code =
77@"using Csla;
78
79public class A : BusinessBase<A>
80{
81 [RunLocal]
82 [FetchChild]
83 private void FetchChild() { }
84}";
85 await TestHelpers.RunAnalysisAsync<DoesChildOperationHaveRunLocalAnalyzer>(
86 code, new[] { Constants.AnalyzerIdentifiers.DoesChildOperationHaveRunLocal });
87 }
88 }
89}