| 1 | using CascadeIDE.Cockpit.ComputingUnits; |
| 2 | using CascadeIDE.Cockpit.ComputingUnits.IdeHealth; |
| 3 | using CascadeIDE.Services; |
| 4 | using Xunit; |
| 5 | |
| 6 | namespace CascadeIDE.Tests; |
| 7 | |
| 8 | public sealed class IdeHealthDebugSegmentUnitTests |
| 9 | { |
| 10 | [Fact] |
| 11 | public void Compose_returns_solution_debug_segment_for_solution_scope() |
| 12 | { |
| 13 | var decision = new IdeHealthScopeDecision(IdeHealthScope.Solution, ProjectPath: null); |
| 14 | var snapshot = DebugSessionSnapshot.Empty with { HasActiveSession = true, IsExecutionStopped = false }; |
| 15 | |
| 16 | var segment = IdeHealthDebugSegmentUnit.Default.Compose(decision, snapshot); |
| 17 | |
| 18 | Assert.Equal("Debug: running…", segment.LineText); |
| 19 | Assert.Equal("DBG · run", segment.CockpitShort); |
| 20 | Assert.Equal(IdeHealthScope.Solution, segment.Scope); |
| 21 | Assert.Null(segment.ProjectPath); |
| 22 | } |
| 23 | |
| 24 | [Fact] |
| 25 | public void Compose_returns_project_debug_segment_for_project_scope() |
| 26 | { |
| 27 | var decision = new IdeHealthScopeDecision(IdeHealthScope.Project, "src/App/App.csproj"); |
| 28 | var snapshot = DebugSessionSnapshot.Empty with |
| 29 | { |
| 30 | HasActiveSession = true, |
| 31 | IsExecutionStopped = true, |
| 32 | StackFrames = new (string Name, string? File, int Line)[] { ("Main", "Program.cs", 10) }, |
| 33 | VariableRootScopes = new[] |
| 34 | { |
| 35 | new DebugVariableRootScope("Locals", new[] { new DebugVariableRow("x", "1", "int") }) |
| 36 | } |
| 37 | }; |
| 38 | |
| 39 | var segment = IdeHealthDebugSegmentUnit.Default.Compose(decision, snapshot); |
| 40 | |
| 41 | Assert.Contains("Debug[src/App/App.csproj]: paused · frames 1, vars 1", segment.LineText, StringComparison.Ordinal); |
| 42 | Assert.Equal(IdeHealthScope.Project, segment.Scope); |
| 43 | Assert.Equal("src/App/App.csproj", segment.ProjectPath); |
| 44 | } |
| 45 | |
| 46 | [Fact] |
| 47 | public void IdeHealthDebugSegmentUnit_Default_implements_ICockpitComputeUnit() |
| 48 | { |
| 49 | ICockpitComputeUnit unit = IdeHealthDebugSegmentUnit.Default; |
| 50 | Assert.NotNull(unit); |
| 51 | } |
| 52 | } |
| 53 | |