diff --git a/Source/Csla.Analyzers/Csla.Analyzers.Tests/FindOperationsWithNonSerializableArgumentsAnalyzerTests.cs b/Source/Csla.Analyzers/Csla.Analyzers.Tests/FindOperationsWithNonSerializableArgumentsAnalyzerTests.cs index b58095cd6c..fd6f218bc3 100644 --- a/Source/Csla.Analyzers/Csla.Analyzers.Tests/FindOperationsWithNonSerializableArgumentsAnalyzerTests.cs +++ b/Source/Csla.Analyzers/Csla.Analyzers.Tests/FindOperationsWithNonSerializableArgumentsAnalyzerTests.cs @@ -138,27 +138,6 @@ private void Fetch([Inject] A x) { } await TestHelpers.RunAnalysisAsync(code, []); } - [TestMethod] - public async Task AnalyzeWithMobileObjectAndMethodIsRootOperationWithSerializableArgumentCustomType() - { - var code = - """ - using Csla; - using System; - - [Serializable] - public class A { } - - public class B : BusinessBase - { - [Fetch] - private void Fetch(A x) { } - } - - """; - await TestHelpers.RunAnalysisAsync(code, []); - } - [TestMethod] public async Task AnalyzeWithMobileObjectAndMethodIsChildOperationWithNoArguments() { diff --git a/Source/Csla.Analyzers/Csla.Analyzers.Tests/IsBusinessObjectSerializableAnalyzerTests.cs b/Source/Csla.Analyzers/Csla.Analyzers.Tests/IsBusinessObjectSerializableAnalyzerTests.cs deleted file mode 100644 index 99461073b3..0000000000 --- a/Source/Csla.Analyzers/Csla.Analyzers.Tests/IsBusinessObjectSerializableAnalyzerTests.cs +++ /dev/null @@ -1,86 +0,0 @@ -using Microsoft.CodeAnalysis; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Csla.Analyzers.Tests -{ - [TestClass] - public sealed class IsBusinessObjectSerializableAnalyzerTests - { - [TestMethod] - public void VerifySupportedDiagnostics() - { - var analyzer = new IsBusinessObjectSerializableAnalyzer(); - var diagnostics = analyzer.SupportedDiagnostics; - Assert.AreEqual(1, diagnostics.Length); - - var diagnostic = diagnostics[0]; - Assert.AreEqual(Constants.AnalyzerIdentifiers.IsBusinessObjectSerializable, diagnostic.Id, - nameof(DiagnosticDescriptor.Id)); - Assert.AreEqual(IsBusinessObjectSerializableConstants.Title, diagnostic.Title.ToString(), - nameof(DiagnosticDescriptor.Title)); - Assert.AreEqual(IsBusinessObjectSerializableConstants.Message, diagnostic.MessageFormat.ToString(), - nameof(DiagnosticDescriptor.MessageFormat)); - Assert.AreEqual(Constants.Categories.Usage, diagnostic.Category, - nameof(DiagnosticDescriptor.Category)); - Assert.AreEqual(DiagnosticSeverity.Error, diagnostic.DefaultSeverity, - nameof(DiagnosticDescriptor.DefaultSeverity)); - Assert.AreEqual(HelpUrlBuilder.Build(Constants.AnalyzerIdentifiers.IsBusinessObjectSerializable, nameof(IsBusinessObjectSerializableAnalyzer)), - diagnostic.HelpLinkUri, - nameof(DiagnosticDescriptor.HelpLinkUri)); - } - - [TestMethod] - public async Task AnalyzeWhenClassIsNotMobileObject() - { - var code = "public class A { }"; - await TestHelpers.RunAnalysisAsync(code, []); - } - - [TestMethod] - public async Task AnalyzeWhenClassIsMobileObjectAndIsSerializable() - { - var code = - """ - using Csla; - using System; - - [Serializable] - public class A : BusinessBase{ } - """; - await TestHelpers.RunAnalysisAsync(code, []); - } - - [TestMethod] - public async Task AnalyzeWhenClassIsMobileObjectAndIsNotSerializable() - { - var code = - """ - using Csla; - - public class A : BusinessBase{ } - """; - await TestHelpers.RunAnalysisAsync( - code, [Constants.AnalyzerIdentifiers.IsBusinessObjectSerializable]); - } - - [TestMethod] - public async Task AnalyzeWhenClassIsDerivedFromReadOnlyListBaseAndIsNotSerializable() { - var code = """ - - using Csla; - using System; - - namespace Testnamespace - { - [Serializable] - public class B : BusinessBase {} - - public class A : ReadOnlyListBase {} - } - - """; - - await TestHelpers.RunAnalysisAsync(code, [Constants.AnalyzerIdentifiers.IsBusinessObjectSerializable]); - } - } -} \ No newline at end of file diff --git a/Source/Csla.Analyzers/Csla.Analyzers.Tests/IsBusinessObjectSerializableMakeSerializableCodeFixTests.cs b/Source/Csla.Analyzers/Csla.Analyzers.Tests/IsBusinessObjectSerializableMakeSerializableCodeFixTests.cs deleted file mode 100644 index 700dadb143..0000000000 --- a/Source/Csla.Analyzers/Csla.Analyzers.Tests/IsBusinessObjectSerializableMakeSerializableCodeFixTests.cs +++ /dev/null @@ -1,99 +0,0 @@ -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CodeActions; -using Microsoft.CodeAnalysis.CodeFixes; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Collections.Immutable; - -namespace Csla.Analyzers.Tests -{ - [TestClass] - public sealed class IsBusinessObjectSerializableMakeSerializableCodeFixTests - { - [TestMethod] - public void VerifyGetFixableDiagnosticIds() - { - var fix = new IsBusinessObjectSerializableMakeSerializableCodeFix(); - var ids = fix.FixableDiagnosticIds.ToList(); - - Assert.AreEqual(1, ids.Count, nameof(ids.Count)); - Assert.AreEqual(ids[0], Constants.AnalyzerIdentifiers.IsBusinessObjectSerializable, - nameof(Constants.AnalyzerIdentifiers.IsBusinessObjectSerializable)); - } - - [TestMethod] - public async Task VerifyGetFixesWhenUsingSystemExists() - { - var code = - """ - using Csla; - using System; - - public class A : BusinessBase - { - [Fetch] - public void Fetch() { } - } - """; - var document = TestHelpers.Create(code); - var tree = await document.GetSyntaxTreeAsync(); - var diagnostics = await TestHelpers.GetDiagnosticsAsync(code, new IsBusinessObjectSerializableAnalyzer()); - - var actions = new List(); - var codeActionRegistration = new Action>( - (a, _) => { actions.Add(a); }); - - var fix = new IsBusinessObjectSerializableMakeSerializableCodeFix(); - var codeFixContext = new CodeFixContext(document, diagnostics[0], - codeActionRegistration, new CancellationToken(false)); - await fix.RegisterCodeFixesAsync(codeFixContext); - - Assert.AreEqual(1, actions.Count, nameof(actions.Count)); - - await TestHelpers.VerifyChangesAsync(actions, - IsBusinessObjectSerializableMakeSerializableCodeFixConstants.AddSerializableDescription, document, - (model, newRoot) => - { - Assert.IsTrue(newRoot.DescendantNodes(_ => true).OfType().Any(_ => _.Name.ToString() == "Serializable")); - }); - } - - [TestMethod] - public async Task VerifyGetFixesWhenUsingSystemDoesNotExists() - { - var code = - """ - using Csla; - - public class A : BusinessBase - { - [Fetch] - public void Fetch() { } - } - """; - var document = TestHelpers.Create(code); - var tree = await document.GetSyntaxTreeAsync(); - var diagnostics = await TestHelpers.GetDiagnosticsAsync(code, new IsBusinessObjectSerializableAnalyzer()); - - var actions = new List(); - var codeActionRegistration = new Action>( - (a, _) => { actions.Add(a); }); - - var fix = new IsBusinessObjectSerializableMakeSerializableCodeFix(); - var codeFixContext = new CodeFixContext(document, diagnostics[0], - codeActionRegistration, new CancellationToken(false)); - await fix.RegisterCodeFixesAsync(codeFixContext); - - Assert.AreEqual(1, actions.Count, nameof(actions.Count)); - - await TestHelpers.VerifyChangesAsync(actions, - IsBusinessObjectSerializableMakeSerializableCodeFixConstants.AddSerializableAndUsingDescription, document, - (model, newRoot) => - { - Assert.IsTrue(newRoot.DescendantNodes(_ => true).OfType().Any( - _ => _.Name.GetText().ToString() == "System")); - Assert.IsTrue(newRoot.DescendantNodes(_ => true).OfType().Any(_ => _.Name.ToString() == "Serializable")); - }); - } - } -} \ No newline at end of file