| 1 | using CascadeIDE.Cockpit.ComputingUnits; |
| 2 | using CascadeIDE.Cockpit.ComputingUnits.IdeHealth; |
| 3 | using Xunit; |
| 4 | |
| 5 | namespace CascadeIDE.Tests; |
| 6 | |
| 7 | public sealed class IdeHealthBuildTestsUnitTests |
| 8 | { |
| 9 | [Fact] |
| 10 | public void Compose_returns_solution_segments_without_project_scope() |
| 11 | { |
| 12 | var decision = new IdeHealthScopeDecision(IdeHealthScope.Solution, ProjectPath: null); |
| 13 | |
| 14 | var snapshot = IdeHealthBuildTestsUnit.Default.Compose( |
| 15 | decision, |
| 16 | buildState: new BuildStateSnapshot(true), |
| 17 | testSummary: "", |
| 18 | impactedTestsBadge: 3); |
| 19 | |
| 20 | Assert.Equal("Build: running…", snapshot.Build.LineText); |
| 21 | Assert.Equal(IdeHealthScope.Solution, snapshot.Build.Scope); |
| 22 | Assert.Equal("Tests: impacted 3", snapshot.Tests.LineText); |
| 23 | Assert.Equal(IdeHealthScope.Solution, snapshot.Tests.Scope); |
| 24 | } |
| 25 | |
| 26 | [Fact] |
| 27 | public void Compose_returns_project_segments_with_project_scope() |
| 28 | { |
| 29 | var decision = new IdeHealthScopeDecision(IdeHealthScope.Project, "src/App/App.csproj"); |
| 30 | |
| 31 | var snapshot = IdeHealthBuildTestsUnit.Default.Compose( |
| 32 | decision, |
| 33 | buildState: new BuildStateSnapshot(false, 0, true), |
| 34 | testSummary: "5/5 passed, 0 failed", |
| 35 | impactedTestsBadge: 0); |
| 36 | |
| 37 | Assert.Equal("Build[src/App/App.csproj]: idle · last OK (exit 0)", snapshot.Build.LineText); |
| 38 | Assert.Equal(IdeHealthScope.Project, snapshot.Build.Scope); |
| 39 | Assert.Equal("src/App/App.csproj", snapshot.Build.ProjectPath); |
| 40 | |
| 41 | Assert.Contains("Tests[src/App/App.csproj]: 5/5 passed, 0 failed", snapshot.Tests.LineText, StringComparison.Ordinal); |
| 42 | Assert.Equal(IdeHealthScope.Project, snapshot.Tests.Scope); |
| 43 | Assert.Equal("src/App/App.csproj", snapshot.Tests.ProjectPath); |
| 44 | } |
| 45 | |
| 46 | [Fact] |
| 47 | public void IdeHealthBuildTestsUnit_Default_implements_ICockpitComputeUnit() |
| 48 | { |
| 49 | ICockpitComputeUnit unit = IdeHealthBuildTestsUnit.Default; |
| 50 | Assert.NotNull(unit); |
| 51 | } |
| 52 | } |
| 53 | |