| 1 | using CascadeIDE.Cockpit.ComputingUnits; |
| 2 | using CascadeIDE.Cockpit.ComputingUnits.Launch; |
| 3 | using Xunit; |
| 4 | |
| 5 | namespace CascadeIDE.Tests; |
| 6 | |
| 7 | public sealed class LaunchMcpErrorFormatUnitTests |
| 8 | { |
| 9 | [Fact] |
| 10 | public void FormatResolveFailure_returns_profile_not_found_for_explicit_profile_without_resolve() |
| 11 | { |
| 12 | var readiness = LaunchReadinessSnapshot.NotReady("profile_project_not_found", "Web", @"src\Web\Web.csproj"); |
| 13 | var message = LaunchMcpErrorFormatUnit.Default.FormatResolveFailure(readiness, "Web", @"D:\repo"); |
| 14 | Assert.Equal("# Error: profile_not_found: Web", message); |
| 15 | } |
| 16 | |
| 17 | [Fact] |
| 18 | public void FormatResolveFailure_returns_active_profile_missing_for_implicit_profile_without_resolve() |
| 19 | { |
| 20 | var readiness = LaunchReadinessSnapshot.NotReady("startup_project_missing"); |
| 21 | var message = LaunchMcpErrorFormatUnit.Default.FormatResolveFailure(readiness, null, @"D:\repo"); |
| 22 | Assert.Equal("# Error: active_profile_missing", message); |
| 23 | } |
| 24 | |
| 25 | [Fact] |
| 26 | public void FormatResolveFailure_returns_project_not_found_when_profile_relative_path_is_known() |
| 27 | { |
| 28 | var readiness = new LaunchReadinessSnapshot( |
| 29 | CanAttemptResolve: true, |
| 30 | Source: LaunchReadinessSource.None, |
| 31 | ReasonCode: "profile_project_not_found", |
| 32 | ProfileId: "Web", |
| 33 | ProfileProjectRelative: @"src\Web\Web.csproj", |
| 34 | SelectedProjectFullPath: null); |
| 35 | var message = LaunchMcpErrorFormatUnit.Default.FormatResolveFailure(readiness, "Web", @"D:\repo"); |
| 36 | Assert.Equal("# Error: project_not_found: D:\\repo\\src\\Web\\Web.csproj", message); |
| 37 | } |
| 38 | |
| 39 | [Fact] |
| 40 | public void LaunchMcpErrorFormatUnit_default_implements_ccu_contract() |
| 41 | { |
| 42 | ICockpitComputeUnit unit = LaunchMcpErrorFormatUnit.Default; |
| 43 | Assert.NotNull(unit); |
| 44 | } |
| 45 | } |
| 46 | |