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.
FindRefAndOutParametersInOperationsAnalyzerTests.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.RefOrOutParameterInOperation, diagnostic.Id,
20 nameof(DiagnosticDescriptor.Id));
21 Assert.AreEqual(FindRefAndOutParametersInOperationsAnalyzerConstants.Title, diagnostic.Title.ToString(),
22 nameof(DiagnosticDescriptor.Title));
23 Assert.AreEqual(FindRefAndOutParametersInOperationsAnalyzerConstants.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.RefOrOutParameterInOperation, nameof(FindRefAndOutParametersInOperationsAnalyzer)),
30 diagnostic.HelpLinkUri,
31 nameof(DiagnosticDescriptor.HelpLinkUri));
32 }
33
34 [TestMethod]
36 {
37 var code = "public class A { }";
38 await TestHelpers.RunAnalysisAsync<FindRefAndOutParametersInOperationsAnalyzer>(
39 code, Array.Empty<string>());
40 }
41
42 [TestMethod]
44 {
45 var code =
46@"using Csla;
47
48public class A
49 : BusinessBase<A>
50{
51 public A() { }
52
53 [Fetch]
54 private void Fetch() { }
55}";
56 await TestHelpers.RunAnalysisAsync<FindRefAndOutParametersInOperationsAnalyzer>(
57 code, Array.Empty<string>());
58 }
59
60 [TestMethod]
62 {
63 var code =
64@"using Csla;
65
66public class A
67 : BusinessBase<A>
68{
69 public A() { }
70
71 [Fetch]
72 private void Fetch(string a) { }
73}";
74 await TestHelpers.RunAnalysisAsync<FindRefAndOutParametersInOperationsAnalyzer>(
75 code, Array.Empty<string>());
76 }
77
78 [TestMethod]
80 {
81 var code =
82@"using Csla;
83
84public class A
85 : BusinessBase<A>
86{
87 public A() { }
88
89 [Fetch]
90 private void Fetch(ref string a) { }
91}";
92 await TestHelpers.RunAnalysisAsync<FindRefAndOutParametersInOperationsAnalyzer>(
93 code, new[] { Constants.AnalyzerIdentifiers.RefOrOutParameterInOperation });
94 }
95
96 [TestMethod]
98 {
99 var code =
100@"using Csla;
101
102public class A
103 : BusinessBase<A>
104{
105 public A() { }
106
107 [Fetch]
108 private void Fetch(out string a) { a = string.Empty; }
109}";
110 await TestHelpers.RunAnalysisAsync<FindRefAndOutParametersInOperationsAnalyzer>(
111 code, new[] { Constants.AnalyzerIdentifiers.RefOrOutParameterInOperation });
112 }
113 }
114}