Forge
csharpdeeb25a2
1using CascadeIDE.Cockpit.ComputingUnits;
2using CascadeIDE.Cockpit.ComputingUnits.Launch;
3using Xunit;
4
5namespace CascadeIDE.Tests;
6
7public sealed class LaunchReadinessUnitTests
8{
9 [Fact]
10 public void Compose_prefers_profile_when_profile_project_exists()
11 {
12 var snapshot = LaunchReadinessUnit.Default.Compose(
13 hasSolutionPath: true,
14 hasWorkspaceRoot: true,
15 profileId: "Web",
16 profileProjectRelative: @"src\Web\Web.csproj",
17 profileProjectFullPath: @"D:\repo\src\Web\Web.csproj",
18 startupProjectFullPath: @"D:\repo\src\App\App.csproj");
19
20 Assert.True(snapshot.CanAttemptResolve);
21 Assert.Equal(LaunchReadinessSource.Profile, snapshot.Source);
22 Assert.Equal("Web", snapshot.ProfileId);
23 Assert.Equal(@"D:\repo\src\Web\Web.csproj", snapshot.SelectedProjectFullPath);
24 }
25
26 [Fact]
27 public void Compose_falls_back_to_startup_project_when_profile_project_missing()
28 {
29 var snapshot = LaunchReadinessUnit.Default.Compose(
30 hasSolutionPath: true,
31 hasWorkspaceRoot: true,
32 profileId: "Web",
33 profileProjectRelative: @"src\Web\Web.csproj",
34 profileProjectFullPath: null,
35 startupProjectFullPath: @"D:\repo\src\App\App.csproj");
36
37 Assert.True(snapshot.CanAttemptResolve);
38 Assert.Equal(LaunchReadinessSource.StartupProject, snapshot.Source);
39 Assert.Equal(@"D:\repo\src\App\App.csproj", snapshot.SelectedProjectFullPath);
40 }
41
42 [Fact]
43 public void Compose_returns_not_ready_without_solution_or_workspace()
44 {
45 var noSolution = LaunchReadinessUnit.Default.Compose(
46 hasSolutionPath: false,
47 hasWorkspaceRoot: true,
48 profileId: null,
49 profileProjectRelative: null,
50 profileProjectFullPath: null,
51 startupProjectFullPath: null);
52 Assert.False(noSolution.CanAttemptResolve);
53 Assert.Equal("solution_missing", noSolution.ReasonCode);
54
55 var noWorkspace = LaunchReadinessUnit.Default.Compose(
56 hasSolutionPath: true,
57 hasWorkspaceRoot: false,
58 profileId: null,
59 profileProjectRelative: null,
60 profileProjectFullPath: null,
61 startupProjectFullPath: null);
62 Assert.False(noWorkspace.CanAttemptResolve);
63 Assert.Equal("workspace_root_unresolved", noWorkspace.ReasonCode);
64 }
65
66 [Fact]
67 public void LaunchReadinessUnit_default_and_snapshot_implement_ccu_contracts()
68 {
69 ICockpitComputeUnit unit = LaunchReadinessUnit.Default;
70 Assert.NotNull(unit);
71
72 ICockpitComputeUnitPayload payload = LaunchReadinessUnit.Default.Compose(
73 hasSolutionPath: true,
74 hasWorkspaceRoot: true,
75 profileId: null,
76 profileProjectRelative: null,
77 profileProjectFullPath: null,
78 startupProjectFullPath: @"D:\repo\src\App\App.csproj");
79 Assert.NotNull(payload);
80 }
81}
82
View only · write via MCP/CIDE