From 156055bc5d79baa84b328172cb398c3c651ed179 Mon Sep 17 00:00:00 2001 From: obligaron Date: Tue, 1 Oct 2024 11:44:58 +0200 Subject: [PATCH] SolutionTests: Check if SDK version is installed and if not ignore the test (#266) --- .../SolutionTests.cs | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator.Tests/SolutionTests.cs b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator.Tests/SolutionTests.cs index 799de72fe..c89a02b9b 100644 --- a/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator.Tests/SolutionTests.cs +++ b/Tests/TestProjectGenerator/Reqnroll.TestProjectGenerator.Tests/SolutionTests.cs @@ -27,26 +27,33 @@ public void CreateEmptySolution() } - [Theory] + [SkippableTheory] [InlineData(ProgrammingLanguage.CSharp, "csproj")] [InlineData(ProgrammingLanguage.FSharp, "fsproj")] [InlineData(ProgrammingLanguage.VB, "vbproj")] public void CreateSolutionWithProject(ProgrammingLanguage programmingLanguage, string expectedEnding) { - string folder = Path.Combine(Path.GetTempPath(), "Reqnroll.TestProjectGenerator.Tests", Guid.NewGuid().ToString("N")); + try + { + string folder = Path.Combine(Path.GetTempPath(), "Reqnroll.TestProjectGenerator.Tests", Guid.NewGuid().ToString("N")); - var solution = new Solution("SolutionName"); - var project = new Project("ProjectName", Guid.NewGuid(), programmingLanguage, TargetFramework.Net462, ProjectFormat.New); + var solution = new Solution("SolutionName"); + var project = new Project("ProjectName", Guid.NewGuid(), programmingLanguage, TargetFramework.Net462, ProjectFormat.New); - solution.AddProject(project); + solution.AddProject(project); - var solutionWriter = CreateSolutionWriter(); + var solutionWriter = CreateSolutionWriter(); - solutionWriter.WriteToFileSystem(solution, folder); + solutionWriter.WriteToFileSystem(solution, folder); - File.Exists(Path.Combine(folder, "SolutionName.sln")).Should().BeTrue(); - File.Exists(Path.Combine(folder, "ProjectName", $"ProjectName.{expectedEnding}")).Should().BeTrue(); + File.Exists(Path.Combine(folder, "SolutionName.sln")).Should().BeTrue(); + File.Exists(Path.Combine(folder, "ProjectName", $"ProjectName.{expectedEnding}")).Should().BeTrue(); + } + catch (DotNetSdkNotInstalledException ex) + { + Skip.IfNot(new ConfigurationDriver().PipelineMode, ex.ToString()); + } } } }