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