@@ -2397,66 +2397,71 @@ let sample15NugetAnalyzers toolsPath loaderType workspaceFactory =
23972397
23982398 )
23992399
2400- /// A test that we can load a solution that contains projects inside solution folders, and get the expected structure
2401- let sample16SolutionFoldersTest toolsPath loaderType workspaceFactory =
2402- testCase
2403- $" Can load sample16 solution folders test - {loaderType}"
2404- ( fun () ->
2405-
2406- let projPath = pathForProject `` sample 16 solution folders ``
2407- let slnDir = Path.GetDirectoryName projPath
2408-
2409- let solutionContents =
2410- InspectSln.tryParseSln projPath
2411- |> getResult
2400+ /// Common code for sample16SolutionFoldersSlnTest/sample16SolutionFoldersSlnxTest - they are the same test, but for both /sln/slnx files
2401+ let sample16SolutionFoldersTest testAsset =
2402+
2403+ let projPath = pathForProject testAsset
2404+ let slnDir = Path.GetDirectoryName projPath
2405+
2406+ let solutionContents =
2407+ InspectSln.tryParseSln projPath
2408+ |> getResult
2409+
2410+ let solutionData = solutionContents
2411+
2412+ // There should be 3 items at the solution level - build.fsproj, a 'src' folder and a 'tests' folder
2413+ Expect.equal solutionData.Items.Length 3 " There should be 3 items in the solution"
2414+
2415+ // The first item should be "build.fsproj
2416+ let firstItem = solutionData.Items[ 0 ]
2417+ let expectedBuildProjectPath = Path.Combine( slnDir, " build.fsproj" )
2418+ Expect.equal firstItem.Name expectedBuildProjectPath " Should have the expected build project path"
2419+
2420+ match firstItem.Kind with
2421+ | InspectSln.MSBuildFormat items -> Expect.isEmpty items " we don't currently store anything here"
2422+ | unexpected -> failtestf " Expected a project, but got %A " unexpected
2423+
2424+ // The second item should be the 'src' folder, which should contain proj1.fsproj
2425+ let secondItem = solutionData.Items[ 1 ]
2426+ Expect.equal secondItem.Name " src" " Should have the src folder"
2427+
2428+ match secondItem.Kind with
2429+ | InspectSln.Folder( solutionItems, _) ->
2430+ match solutionItems with
2431+ | [ {
2432+ Name = folderName
2433+ Kind = InspectSln.MSBuildFormat []
2434+ } ] ->
2435+ let expectedProjectPath = Path.Combine( slnDir, " src" , " proj1" , " proj1.fsproj" )
2436+ Expect.equal folderName expectedProjectPath " Should have the expected project path"
2437+ | _ -> failtestf " Expected one folder item, but got %A " solutionItems
2438+ | unexpected -> failtestf " Expected a folder, but got %A " unexpected
2439+
2440+ // The third item should be the 'src' folder, which should contain proj1.fsproj
2441+ let thirdItem = solutionData.Items[ 2 ]
2442+ Expect.equal thirdItem.Name " tests" " Should have the tests folder"
2443+
2444+ match thirdItem.Kind with
2445+ | InspectSln.Folder( solutionItems, _) ->
2446+ match solutionItems with
2447+ | [ {
2448+ Name = folderName
2449+ Kind = InspectSln.MSBuildFormat []
2450+ } ] ->
2451+ let expectedProjectPath = Path.Combine( slnDir, " test" , " proj1.tests" , " proj1.tests.fsproj" )
2452+ Expect.equal folderName expectedProjectPath " Should have the expected test project path"
2453+ | _ -> failtestf " Expected one folder item, but got %A " solutionItems
2454+ | unexpected -> failtestf " Expected a folder, but got %A " unexpected
24122455
2413- let solutionData = solutionContents
2456+ /// A test that we can load a solution that contains projects inside solution folders, and get the expected structure
2457+ let sample16SolutionFoldersSlnTest toolsPath loaderType workspaceFactory =
24142458
2415- // There should be 3 items at the solution level - build.fsproj, a 'src' folder and a 'tests' folder
2416- Expect.equal solutionData.Items.Length 3 " There should be 3 items in the solution"
2459+ testCase $" Can load sample16 solution folders test (.sln) - {loaderType}" ( fun () -> sample16SolutionFoldersTest `` sample 16 solution folders (.sln) `` )
24172460
2418- // The first item should be "build.fsproj
2419- let firstItem = solutionData.Items[ 0 ]
2420- let expectedBuildProjectPath = Path.Combine( slnDir, " build.fsproj" )
2421- Expect.equal firstItem.Name expectedBuildProjectPath " Should have the expected build project path"
2422-
2423- match firstItem.Kind with
2424- | InspectSln.MSBuildFormat items -> Expect.isEmpty items " we don't currently store anything here"
2425- | unexpected -> failtestf " Expected a project, but got %A " unexpected
2426-
2427- // The second item should be the 'src' folder, which should contain proj1.fsproj
2428- let secondItem = solutionData.Items[ 1 ]
2429- Expect.equal secondItem.Name " src" " Should have the src folder"
2430-
2431- match secondItem.Kind with
2432- | InspectSln.Folder( solutionItems, _) ->
2433- match solutionItems with
2434- | [ {
2435- Name = folderName
2436- Kind = InspectSln.MSBuildFormat []
2437- } ] ->
2438- let expectedProjectPath = Path.Combine( slnDir, " src" , " proj1" , " proj1.fsproj" )
2439- Expect.equal folderName expectedProjectPath " Should have the expected project path"
2440- | _ -> failtestf " Expected one folder item, but got %A " solutionItems
2441- | unexpected -> failtestf " Expected a folder, but got %A " unexpected
2442-
2443- // The third item should be the 'src' folder, which should contain proj1.fsproj
2444- let thirdItem = solutionData.Items[ 2 ]
2445- Expect.equal thirdItem.Name " tests" " Should have the tests folder"
2446-
2447- match thirdItem.Kind with
2448- | InspectSln.Folder( solutionItems, _) ->
2449- match solutionItems with
2450- | [ {
2451- Name = folderName
2452- Kind = InspectSln.MSBuildFormat []
2453- } ] ->
2454- let expectedProjectPath = Path.Combine( slnDir, " test" , " proj1.tests" , " proj1.tests.fsproj" )
2455- Expect.equal folderName expectedProjectPath " Should have the expected test project path"
2456- | _ -> failtestf " Expected one folder item, but got %A " solutionItems
2457- | unexpected -> failtestf " Expected a folder, but got %A " unexpected
2458- )
2461+ /// As above, but for a .slnx format solution
2462+ let sample16SolutionFoldersSlnxTest toolsPath loaderType workspaceFactory =
24592463
2464+ testCase $" Can load sample16 solution folders test (.slnx) - {loaderType}" ( fun () -> sample16SolutionFoldersTest `` sample 16 solution folders (.slnx) `` )
24602465
24612466let tests toolsPath =
24622467 let testSample3WorkspaceLoaderExpected = [
@@ -2600,6 +2605,9 @@ let tests toolsPath =
26002605 sample15NugetAnalyzers toolsPath ( nameof ( WorkspaceLoader)) WorkspaceLoader.Create
26012606 sample15NugetAnalyzers toolsPath ( nameof ( WorkspaceLoaderViaProjectGraph)) WorkspaceLoaderViaProjectGraph.Create
26022607
2603- sample16SolutionFoldersTest toolsPath ( nameof ( WorkspaceLoader)) WorkspaceLoader.Create
2604- sample16SolutionFoldersTest toolsPath ( nameof ( WorkspaceLoaderViaProjectGraph)) WorkspaceLoaderViaProjectGraph.Create
2608+ sample16SolutionFoldersSlnTest toolsPath ( nameof ( WorkspaceLoader)) WorkspaceLoader.Create
2609+ sample16SolutionFoldersSlnTest toolsPath ( nameof ( WorkspaceLoaderViaProjectGraph)) WorkspaceLoaderViaProjectGraph.Create
2610+
2611+ sample16SolutionFoldersSlnxTest toolsPath ( nameof ( WorkspaceLoader)) WorkspaceLoader.Create
2612+ sample16SolutionFoldersSlnxTest toolsPath ( nameof ( WorkspaceLoaderViaProjectGraph)) WorkspaceLoaderViaProjectGraph.Create
26052613 ]
0 commit comments