diff --git a/tests/DendroDocs.Tool.Tests/AnalyzerSetup/AnalyzerSetupTests.cs b/tests/DendroDocs.Tool.Tests/AnalyzerSetup/AnalyzerSetupTests.cs index b246a70..a877ca1 100644 --- a/tests/DendroDocs.Tool.Tests/AnalyzerSetup/AnalyzerSetupTests.cs +++ b/tests/DendroDocs.Tool.Tests/AnalyzerSetup/AnalyzerSetupTests.cs @@ -3,13 +3,13 @@ namespace DendroDocs.Tool.Tests; [TestClass] public class AnalyzerSetupTests { - private static readonly string solutionPath = GetSolutionPath(); + private static readonly string SolutionPath = GetSolutionPath(); [TestMethod] public void SolutionShouldLoadAllProjects() { // Arrange - var solutionFile = Path.Combine(solutionPath, "SolutionWithoutTests.sln"); + var solutionFile = Path.Combine(SolutionPath, "SolutionWithoutTests.sln"); // Act using var analyzerSetup = AnalyzerSetup.BuildSolutionAnalyzer(solutionFile); @@ -17,16 +17,16 @@ public void SolutionShouldLoadAllProjects() // Assert analyzerSetup.Projects.Should().HaveCount(3); analyzerSetup.Projects.Should().Satisfy( - p => p.FilePath.EndsWith("Project.csproj"), - p => p.FilePath.EndsWith("OtherProject.csproj"), - p => p.FilePath.EndsWith("AnotherProject.csproj")); + p => p.FilePath != null && p.FilePath.EndsWith("Project.csproj"), + p => p.FilePath != null && p.FilePath.EndsWith("OtherProject.csproj"), + p => p.FilePath != null && p.FilePath.EndsWith("AnotherProject.csproj")); } [TestMethod] public void SolutionShouldFilterTestProjects() { // Arrange - var solutionFile = Path.Combine(solutionPath, "SolutionWithTests.sln"); + var solutionFile = Path.Combine(SolutionPath, "SolutionWithTests.sln"); // Act using var analyzerSetup = AnalyzerSetup.BuildSolutionAnalyzer(solutionFile); @@ -34,17 +34,17 @@ public void SolutionShouldFilterTestProjects() // Assert analyzerSetup.Projects.Should().HaveCount(3); analyzerSetup.Projects.Should().Satisfy( - p => p.FilePath.EndsWith("Project.csproj"), - p => p.FilePath.EndsWith("OtherProject.csproj"), - p => p.FilePath.EndsWith("AnotherProject.csproj")); + p => p.FilePath != null && p.FilePath.EndsWith("Project.csproj"), + p => p.FilePath != null && p.FilePath.EndsWith("OtherProject.csproj"), + p => p.FilePath != null && p.FilePath.EndsWith("AnotherProject.csproj")); } [TestMethod] public void SolutionShouldFilterExcludedProject() { // Arrange - var solutionFile = Path.Combine(solutionPath, "SolutionWithoutTests.sln"); - var excludeProjectFile = Path.Combine(solutionPath, "OtherProject", "OtherProject.csproj"); + var solutionFile = Path.Combine(SolutionPath, "SolutionWithoutTests.sln"); + var excludeProjectFile = Path.Combine(SolutionPath, "OtherProject", "OtherProject.csproj"); // Act using var analyzerSetup = AnalyzerSetup.BuildSolutionAnalyzer(solutionFile, [excludeProjectFile]); @@ -52,38 +52,38 @@ public void SolutionShouldFilterExcludedProject() // Assert analyzerSetup.Projects.Should().HaveCount(2); analyzerSetup.Projects.Should().Satisfy( - p => p.FilePath.EndsWith("Project.csproj"), - p => p.FilePath.EndsWith("AnotherProject.csproj")); + p => p.FilePath != null && p.FilePath.EndsWith("Project.csproj"), + p => p.FilePath != null && p.FilePath.EndsWith("AnotherProject.csproj")); } [TestMethod] public void SolutionShouldFilterExcludedProjects() { // Arrange - var solutionFile = Path.Combine(solutionPath, "SolutionWithoutTests.sln"); - var excludeProjectFile1 = Path.Combine(solutionPath, "OtherProject", "OtherProject.csproj"); - var excludeProjectFile2 = Path.Combine(solutionPath, "AnotherProject", "AnotherProject.csproj"); + var solutionFile = Path.Combine(SolutionPath, "SolutionWithoutTests.sln"); + var excludeProjectFile1 = Path.Combine(SolutionPath, "OtherProject", "OtherProject.csproj"); + var excludeProjectFile2 = Path.Combine(SolutionPath, "AnotherProject", "AnotherProject.csproj"); // Act using var analyzerSetup = AnalyzerSetup.BuildSolutionAnalyzer(solutionFile, [excludeProjectFile1, excludeProjectFile2]); // Assert analyzerSetup.Projects.Should().HaveCount(1); - analyzerSetup.Projects.Should().Satisfy(p => p.FilePath.EndsWith("Project.csproj")); + analyzerSetup.Projects.Should().Satisfy(p => p.FilePath != null && p.FilePath.EndsWith("Project.csproj")); } [TestMethod] public void SolutionShouldLoadProject() { // Arrange - var projectFile = Path.Combine(solutionPath, "Project", "Project.csproj"); + var projectFile = Path.Combine(SolutionPath, "Project", "Project.csproj"); // Act using var analyzerSetup = AnalyzerSetup.BuildProjectAnalyzer(projectFile); // Assert analyzerSetup.Projects.Should().HaveCount(1); - analyzerSetup.Projects.Should().Satisfy(p => p.FilePath.EndsWith("Project.csproj")); + analyzerSetup.Projects.Should().Satisfy(p => p.FilePath != null && p.FilePath.EndsWith("Project.csproj")); } private static string GetSolutionPath() diff --git a/tests/DendroDocs.Tool.Tests/DocumentationCommentsTests.cs b/tests/DendroDocs.Tool.Tests/DocumentationCommentsTests.cs index 1dee27a..c88b35d 100644 --- a/tests/DendroDocs.Tool.Tests/DocumentationCommentsTests.cs +++ b/tests/DendroDocs.Tool.Tests/DocumentationCommentsTests.cs @@ -28,9 +28,9 @@ class Test // Assert using (new AssertionScope()) { - types[0].DocumentationComments.Summary.Should().Be("This is a Test Class."); - types[0].DocumentationComments.Remarks.Should().Be("This is a remark."); - types[0].DocumentationComments.Example.Should().Be("This is an example."); + types[0].DocumentationComments?.Summary.Should().Be("This is a Test Class."); + types[0].DocumentationComments?.Remarks.Should().Be("This is a remark."); + types[0].DocumentationComments?.Example.Should().Be("This is an example."); } } @@ -65,10 +65,10 @@ class Test // Assert using (new AssertionScope()) { - types[0].Events[0].DocumentationComments.Summary.Should().Be("This is a Test Event."); - types[0].Events[0].DocumentationComments.Remarks.Should().Be("This is a remark."); - types[0].Events[0].DocumentationComments.Example.Should().Be("This is an example."); - types[0].Events[0].DocumentationComments.Value.Should().Be("This is the value."); + types[0].Events[0].DocumentationComments?.Summary.Should().Be("This is a Test Event."); + types[0].Events[0].DocumentationComments?.Remarks.Should().Be("This is a remark."); + types[0].Events[0].DocumentationComments?.Example.Should().Be("This is an example."); + types[0].Events[0].DocumentationComments?.Value.Should().Be("This is the value."); } } @@ -103,15 +103,15 @@ class Test // Assert using (new AssertionScope()) { - types[0].Events[0].DocumentationComments.Summary.Should().Be("These are Test Events."); - types[0].Events[0].DocumentationComments.Remarks.Should().Be("This is a remark."); - types[0].Events[0].DocumentationComments.Example.Should().Be("This is an example."); - types[0].Events[0].DocumentationComments.Value.Should().Be("This is the value."); - - types[0].Events[1].DocumentationComments.Summary.Should().Be("These are Test Events."); - types[0].Events[1].DocumentationComments.Remarks.Should().Be("This is a remark."); - types[0].Events[1].DocumentationComments.Example.Should().Be("This is an example."); - types[0].Events[1].DocumentationComments.Value.Should().Be("This is the value."); + types[0].Events[0].DocumentationComments?.Summary.Should().Be("These are Test Events."); + types[0].Events[0].DocumentationComments?.Remarks.Should().Be("This is a remark."); + types[0].Events[0].DocumentationComments?.Example.Should().Be("This is an example."); + types[0].Events[0].DocumentationComments?.Value.Should().Be("This is the value."); + + types[0].Events[1].DocumentationComments?.Summary.Should().Be("These are Test Events."); + types[0].Events[1].DocumentationComments?.Remarks.Should().Be("This is a remark."); + types[0].Events[1].DocumentationComments?.Example.Should().Be("This is an example."); + types[0].Events[1].DocumentationComments?.Value.Should().Be("This is the value."); } } @@ -144,10 +144,10 @@ public class Test // Assert using (new AssertionScope()) { - types[0].Fields[0].DocumentationComments.Summary.Should().Be("This is a Test Field."); - types[0].Fields[0].DocumentationComments.Remarks.Should().Be("This is a remark."); - types[0].Fields[0].DocumentationComments.Example.Should().Be("This is an example."); - types[0].Fields[0].DocumentationComments.Value.Should().Be("This is the value."); + types[0].Fields[0].DocumentationComments?.Summary.Should().Be("This is a Test Field."); + types[0].Fields[0].DocumentationComments?.Remarks.Should().Be("This is a remark."); + types[0].Fields[0].DocumentationComments?.Example.Should().Be("This is an example."); + types[0].Fields[0].DocumentationComments?.Value.Should().Be("This is the value."); } } @@ -180,15 +180,15 @@ public class Test // Assert using (new AssertionScope()) { - types[0].Fields[0].DocumentationComments.Summary.Should().Be("These are Test Fields."); - types[0].Fields[0].DocumentationComments.Remarks.Should().Be("This is a remark."); - types[0].Fields[0].DocumentationComments.Example.Should().Be("This is an example."); - types[0].Fields[0].DocumentationComments.Value.Should().Be("This is the value."); - - types[0].Fields[1].DocumentationComments.Summary.Should().Be("These are Test Fields."); - types[0].Fields[1].DocumentationComments.Remarks.Should().Be("This is a remark."); - types[0].Fields[1].DocumentationComments.Example.Should().Be("This is an example."); - types[0].Fields[1].DocumentationComments.Value.Should().Be("This is the value."); + types[0].Fields[0].DocumentationComments?.Summary.Should().Be("These are Test Fields."); + types[0].Fields[0].DocumentationComments?.Remarks.Should().Be("This is a remark."); + types[0].Fields[0].DocumentationComments?.Example.Should().Be("This is an example."); + types[0].Fields[0].DocumentationComments?.Value.Should().Be("This is the value."); + + types[0].Fields[1].DocumentationComments?.Summary.Should().Be("These are Test Fields."); + types[0].Fields[1].DocumentationComments?.Remarks.Should().Be("This is a remark."); + types[0].Fields[1].DocumentationComments?.Example.Should().Be("This is an example."); + types[0].Fields[1].DocumentationComments?.Value.Should().Be("This is the value."); } } @@ -217,9 +217,9 @@ interface Test // Assert using (new AssertionScope()) { - types[0].DocumentationComments.Summary.Should().Be("This is a Test Interface."); - types[0].DocumentationComments.Remarks.Should().Be("This is a remark."); - types[0].DocumentationComments.Example.Should().Be("This is an example."); + types[0].DocumentationComments?.Summary.Should().Be("This is a Test Interface."); + types[0].DocumentationComments?.Remarks.Should().Be("This is a remark."); + types[0].DocumentationComments?.Example.Should().Be("This is an example."); } } @@ -248,9 +248,9 @@ enum Test // Assert using (new AssertionScope()) { - types[0].DocumentationComments.Summary.Should().Be("This is a Test Enum."); - types[0].DocumentationComments.Remarks.Should().Be("This is a remark."); - types[0].DocumentationComments.Example.Should().Be("This is an example."); + types[0].DocumentationComments?.Summary.Should().Be("This is a Test Enum."); + types[0].DocumentationComments?.Remarks.Should().Be("This is a remark."); + types[0].DocumentationComments?.Example.Should().Be("This is an example."); } } @@ -279,9 +279,9 @@ struct Test // Assert using (new AssertionScope()) { - types[0].DocumentationComments.Summary.Should().Be("This is a Test Struct."); - types[0].DocumentationComments.Remarks.Should().Be("This is a remark."); - types[0].DocumentationComments.Example.Should().Be("This is an example."); + types[0].DocumentationComments?.Summary.Should().Be("This is a Test Struct."); + types[0].DocumentationComments?.Remarks.Should().Be("This is a remark."); + types[0].DocumentationComments?.Example.Should().Be("This is an example."); } } @@ -314,10 +314,10 @@ class Test // Assert using (new AssertionScope()) { - types[0].Methods[0].DocumentationComments.Summary.Should().Be("This is a Test Method."); - types[0].Methods[0].DocumentationComments.Remarks.Should().Be("This is a remark."); - types[0].Methods[0].DocumentationComments.Example.Should().Be("This is an example."); - types[0].Methods[0].DocumentationComments.Returns.Should().Be("Returns a string."); + types[0].Methods[0].DocumentationComments?.Summary.Should().Be("This is a Test Method."); + types[0].Methods[0].DocumentationComments?.Remarks.Should().Be("This is a remark."); + types[0].Methods[0].DocumentationComments?.Example.Should().Be("This is an example."); + types[0].Methods[0].DocumentationComments?.Returns.Should().Be("Returns a string."); } } @@ -350,10 +350,10 @@ class Test // Assert using (new AssertionScope()) { - types[0].Constructors[0].DocumentationComments.Summary.Should().Be("This is a Test Constructor."); - types[0].Constructors[0].DocumentationComments.Remarks.Should().Be("This is a remark."); - types[0].Constructors[0].DocumentationComments.Example.Should().Be("This is an example."); - types[0].Constructors[0].DocumentationComments.Returns.Should().Be("Returns a string."); + types[0].Constructors[0].DocumentationComments?.Summary.Should().Be("This is a Test Constructor."); + types[0].Constructors[0].DocumentationComments?.Remarks.Should().Be("This is a remark."); + types[0].Constructors[0].DocumentationComments?.Example.Should().Be("This is an example."); + types[0].Constructors[0].DocumentationComments?.Returns.Should().Be("Returns a string."); } } @@ -386,10 +386,10 @@ class Test // Assert using (new AssertionScope()) { - types[0].Properties[0].DocumentationComments.Summary.Should().Be("This is a Test Property."); - types[0].Properties[0].DocumentationComments.Remarks.Should().Be("This is a remark."); - types[0].Properties[0].DocumentationComments.Example.Should().Be("This is an example."); - types[0].Properties[0].DocumentationComments.Value.Should().Be("This is the value."); + types[0].Properties[0].DocumentationComments?.Summary.Should().Be("This is a Test Property."); + types[0].Properties[0].DocumentationComments?.Remarks.Should().Be("This is a remark."); + types[0].Properties[0].DocumentationComments?.Example.Should().Be("This is an example."); + types[0].Properties[0].DocumentationComments?.Value.Should().Be("This is the value."); } } }