| 1 | using CascadeIDE.Services; |
| 2 | using Xunit; |
| 3 | |
| 4 | namespace CascadeIDE.Tests; |
| 5 | |
| 6 | public sealed class SolutionParserStandaloneProjectTests |
| 7 | { |
| 8 | [Fact] |
| 9 | public void Load_CsprojPath_BuildsTreeWithSingleProjectChild() |
| 10 | { |
| 11 | var dir = Path.Combine(Path.GetTempPath(), "cascade_standalone_proj_" + Guid.NewGuid().ToString("N")); |
| 12 | Directory.CreateDirectory(dir); |
| 13 | try |
| 14 | { |
| 15 | var csPath = Path.Combine(dir, "Lib.cs"); |
| 16 | File.WriteAllText(csPath, "// file"); |
| 17 | var csproj = Path.Combine(dir, "Standalone.csproj"); |
| 18 | File.WriteAllText(csproj, """ |
| 19 | <Project Sdk="Microsoft.NET.Sdk"> |
| 20 | <PropertyGroup> |
| 21 | <TargetFramework>net10.0</TargetFramework> |
| 22 | <Nullable>enable</Nullable> |
| 23 | </PropertyGroup> |
| 24 | </Project> |
| 25 | """); |
| 26 | |
| 27 | var root = SolutionParser.Load(csproj, out var err); |
| 28 | Assert.Null(err); |
| 29 | Assert.NotNull(root); |
| 30 | Assert.Equal("Standalone", root!.Title); |
| 31 | Assert.Equal(csproj, root.FullPath); |
| 32 | Assert.Single(root.Children); |
| 33 | var proj = root.Children[0]; |
| 34 | Assert.Equal("Standalone.csproj", proj.Title); |
| 35 | Assert.Equal(csproj, proj.FullPath); |
| 36 | } |
| 37 | finally |
| 38 | { |
| 39 | try { Directory.Delete(dir, true); } catch { /* test temp */ } |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | |