| 1 | using CascadeIDE.Cockpit.ComputingUnits.IdeHealth; |
| 2 | using CascadeIDE.Services; |
| 3 | using Xunit; |
| 4 | |
| 5 | namespace CascadeIDE.Tests; |
| 6 | |
| 7 | public sealed class IdeHealthDebugSummaryUnitTests |
| 8 | { |
| 9 | [Fact] |
| 10 | public void Summarize_returns_idle_without_active_session() |
| 11 | { |
| 12 | var summary = IdeHealthDebugSummaryUnit.Default.Summarize(DebugSessionSnapshot.Empty); |
| 13 | Assert.Equal("idle", summary); |
| 14 | } |
| 15 | |
| 16 | [Fact] |
| 17 | public void Summarize_returns_running_for_active_non_stopped_session() |
| 18 | { |
| 19 | var snapshot = DebugSessionSnapshot.Empty with { HasActiveSession = true, IsExecutionStopped = false }; |
| 20 | var summary = IdeHealthDebugSummaryUnit.Default.Summarize(snapshot); |
| 21 | Assert.Equal("running…", summary); |
| 22 | } |
| 23 | |
| 24 | [Fact] |
| 25 | public void Summarize_returns_paused_with_frames_and_variables() |
| 26 | { |
| 27 | var snapshot = DebugSessionSnapshot.Empty with |
| 28 | { |
| 29 | HasActiveSession = true, |
| 30 | IsExecutionStopped = true, |
| 31 | StackFrames = new (string Name, string? File, int Line)[] { ("Main", "Program.cs", 10), ("Worker", "Worker.cs", 42) }, |
| 32 | VariableRootScopes = new[] |
| 33 | { |
| 34 | new DebugVariableRootScope("Locals", new[] { new DebugVariableRow("a", "1", "int"), new DebugVariableRow("b", "\"x\"", "string") }), |
| 35 | new DebugVariableRootScope("Arguments", new[] { new DebugVariableRow("arg", "true", "bool") }) |
| 36 | } |
| 37 | }; |
| 38 | |
| 39 | var summary = IdeHealthDebugSummaryUnit.Default.Summarize(snapshot); |
| 40 | Assert.Equal("paused · frames 2, vars 3", summary); |
| 41 | } |
| 42 | } |
| 43 | |