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.
EvaluateOperationAttributeUsageAnalyzerTests.cs
Go to the documentation of this file.
1using Microsoft.CodeAnalysis;
2using Microsoft.VisualStudio.TestTools.UnitTesting;
3using System;
4using System.Linq;
5using System.Threading.Tasks;
6
8{
9 [TestClass]
11 {
12 [TestMethod]
14 {
15 var analyzer = new EvaluateOperationAttributeUsageAnalyzer();
16 var diagnostics = analyzer.SupportedDiagnostics;
17 Assert.AreEqual(1, diagnostics.Length);
18
19 var diagnostic = diagnostics.Single(_ => _.Id == Constants.AnalyzerIdentifiers.IsOperationAttributeUsageCorrect);
20 Assert.AreEqual(EvaluateOperationAttributeUsageAnalyzerConstants.Title, diagnostic.Title.ToString(),
21 nameof(DiagnosticDescriptor.Title));
22 Assert.AreEqual(EvaluateOperationAttributeUsageAnalyzerConstants.Message, diagnostic.MessageFormat.ToString(),
23 nameof(DiagnosticDescriptor.MessageFormat));
24 Assert.AreEqual(Constants.Categories.Usage, diagnostic.Category,
25 nameof(DiagnosticDescriptor.Category));
26 Assert.AreEqual(DiagnosticSeverity.Error, diagnostic.DefaultSeverity,
27 nameof(DiagnosticDescriptor.DefaultSeverity));
28 Assert.AreEqual(HelpUrlBuilder.Build(Constants.AnalyzerIdentifiers.IsOperationAttributeUsageCorrect, nameof(EvaluateOperationAttributeUsageAnalyzer)),
29 diagnostic.HelpLinkUri,
30 nameof(DiagnosticDescriptor.HelpLinkUri));
31 }
32
33 [TestMethod]
35 {
36 var code =
37@"using Csla;
38
39public class A
40{
41 [Fetch]
42 private void Fetch() { }
43}";
44 await TestHelpers.RunAnalysisAsync<EvaluateOperationAttributeUsageAnalyzer>(
45 code, new[] { Constants.AnalyzerIdentifiers.IsOperationAttributeUsageCorrect });
46 }
47
48 [TestMethod]
50 {
51 var code =
52@"using Csla;
53using System;
54
55[Serializable]
56public class A
57 : BusinessBase<A>
58{
59 [Fetch]
60 private static void Fetch() { }
61}";
62 await TestHelpers.RunAnalysisAsync<EvaluateOperationAttributeUsageAnalyzer>(
63 code, new[] { Constants.AnalyzerIdentifiers.IsOperationAttributeUsageCorrect });
64 }
65
66 [TestMethod]
68 {
69 var code =
70@"using Csla;
71using System;
72
73[Serializable]
74public class A
75 : BusinessBase<A>
76{
77 [Fetch]
78 private void Fetch() { }
79}";
80 await TestHelpers.RunAnalysisAsync<EvaluateOperationAttributeUsageAnalyzer>(
81 code, Array.Empty<string>());
82 }
83 }
84}