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.
IsBusinessObjectSerializableAnalyzerTests.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]
10 {
11 [TestMethod]
13 {
14 var analyzer = new IsBusinessObjectSerializableAnalyzer();
15 var diagnostics = analyzer.SupportedDiagnostics;
16 Assert.AreEqual(1, diagnostics.Length);
17
18 var diagnostic = diagnostics[0];
19 Assert.AreEqual(Constants.AnalyzerIdentifiers.IsBusinessObjectSerializable, diagnostic.Id,
20 nameof(DiagnosticDescriptor.Id));
21 Assert.AreEqual(IsBusinessObjectSerializableConstants.Title, diagnostic.Title.ToString(),
22 nameof(DiagnosticDescriptor.Title));
23 Assert.AreEqual(IsBusinessObjectSerializableConstants.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.IsBusinessObjectSerializable, nameof(IsBusinessObjectSerializableAnalyzer)),
30 diagnostic.HelpLinkUri,
31 nameof(DiagnosticDescriptor.HelpLinkUri));
32 }
33
34 [TestMethod]
36 {
37 var code = "public class A { }";
38 await TestHelpers.RunAnalysisAsync<IsBusinessObjectSerializableAnalyzer>(
39 code, Array.Empty<string>());
40 }
41
42 [TestMethod]
44 {
45 var code =
46@"using Csla;
47using System;
48
49[Serializable]
50public class A : BusinessBase<A>{ }";
51 await TestHelpers.RunAnalysisAsync<IsBusinessObjectSerializableAnalyzer>(
52 code, Array.Empty<string>());
53 }
54
55 [TestMethod]
57 {
58 var code =
59@"using Csla;
60
61public class A : BusinessBase<A>{ }";
62 await TestHelpers.RunAnalysisAsync<IsBusinessObjectSerializableAnalyzer>(
63 code, new[] { Constants.AnalyzerIdentifiers.IsBusinessObjectSerializable });
64 }
65 }
66}