Skip to content

Commit a6f2944

Browse files
committed
Add a simple unit test for reading an slnx file
1 parent 12760d4 commit a6f2944

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed

test/Ionide.ProjInfo.Tests/TestAssets.fs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,3 +357,12 @@ let ``sample 13 sln with solution files`` = {
357357
TargetFrameworks = Map.empty
358358
ProjectReferences = []
359359
}
360+
361+
// A test with a .slnx format solution file
362+
let ``sample 14 slnx solution`` = {
363+
ProjDir = "sample-14-slnx-solution"
364+
AssemblyName = ""
365+
ProjectFile = "sample-14-slnx-solution.slnx"
366+
TargetFrameworks = Map.empty
367+
ProjectReferences = []
368+
}

test/Ionide.ProjInfo.Tests/Tests.fs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,6 +2331,28 @@ let sample13SolutionFilesTest toolsPath loaderType workspaceFactory =
23312331
| _ -> failtestf "Expected a folder, but got %A" solutionItem.Kind
23322332
)
23332333

2334+
let sample14SlnxFileTest toolsPath loaderType workspaceFactory =
2335+
testCase
2336+
$"Can load sample14 slnx file test - {loaderType}"
2337+
(fun () ->
2338+
2339+
let projPath = pathForProject ``sample 14 slnx solution``
2340+
let slnDir = Path.GetDirectoryName projPath
2341+
2342+
let solutionContents =
2343+
InspectSln.tryParseSln projPath
2344+
|> getResult
2345+
2346+
let expectedProject = solutionContents.Items[0]
2347+
2348+
let expectedProjectPath = Path.Combine(slnDir, "proj1", "proj1.fsproj")
2349+
Expect.equal expectedProject.Name expectedProjectPath "Should have the expected project path"
2350+
2351+
match expectedProject.Kind with
2352+
| InspectSln.MSBuildFormat items -> Expect.isEmpty items "we don't currently store anything here"
2353+
| _ -> failtestf "Expected a project, but got %A" expectedProject.Kind
2354+
)
2355+
23342356
let tests toolsPath =
23352357
let testSample3WorkspaceLoaderExpected = [
23362358
ExpectNotification.loading "c1.fsproj"
@@ -2466,4 +2488,7 @@ let tests toolsPath =
24662488

24672489
sample13SolutionFilesTest toolsPath (nameof (WorkspaceLoader)) WorkspaceLoader.Create
24682490
sample13SolutionFilesTest toolsPath (nameof (WorkspaceLoaderViaProjectGraph)) WorkspaceLoaderViaProjectGraph.Create
2491+
2492+
sample14SlnxFileTest toolsPath (nameof (WorkspaceLoader)) WorkspaceLoader.Create
2493+
sample14SlnxFileTest toolsPath (nameof (WorkspaceLoaderViaProjectGraph)) WorkspaceLoaderViaProjectGraph.Create
24692494
]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespace proj1
2+
3+
module Say =
4+
let hello name =
5+
printfn "Hello %s" name
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<Compile Include="Library.fs" />
10+
</ItemGroup>
11+
12+
</Project>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Solution>
2+
<Project Path="proj1/proj1.fsproj" />
3+
</Solution>

0 commit comments

Comments
 (0)