| 1 | using CascadeIDE.Cockpit.ComputingUnits.IdeHealth; |
| 2 | using CascadeIDE.Cockpit.DataBus; |
| 3 | using Xunit; |
| 4 | |
| 5 | namespace CascadeIDE.Tests; |
| 6 | |
| 7 | public sealed class BuildStateSnapshotUnitTests |
| 8 | { |
| 9 | [Fact] |
| 10 | public void Apply_running_sets_IsBuilding_preserves_last() |
| 11 | { |
| 12 | var prior = new BuildStateSnapshot(false, 0, true); |
| 13 | var next = BuildStateSnapshotUnit.Apply(prior, new BuildStateChanged(true)); |
| 14 | Assert.True(next.IsBuilding); |
| 15 | Assert.Equal(0, next.LastExitCode); |
| 16 | Assert.True(next.LastBuildSucceeded); |
| 17 | } |
| 18 | |
| 19 | [Fact] |
| 20 | public void Apply_finish_updates_last_result() |
| 21 | { |
| 22 | var prior = BuildStateSnapshot.Empty; |
| 23 | var after = BuildStateSnapshotUnit.Apply(prior, new BuildStateChanged(false, 3, false)); |
| 24 | Assert.False(after.IsBuilding); |
| 25 | Assert.Equal(3, after.LastExitCode); |
| 26 | Assert.False(after.LastBuildSucceeded); |
| 27 | } |
| 28 | |
| 29 | [Fact] |
| 30 | public void Apply_idle_without_metrics_keeps_prior_last() |
| 31 | { |
| 32 | var prior = new BuildStateSnapshot(false, 0, true); |
| 33 | var after = BuildStateSnapshotUnit.Apply(prior, new BuildStateChanged(false)); |
| 34 | Assert.False(after.IsBuilding); |
| 35 | Assert.Equal(0, after.LastExitCode); |
| 36 | Assert.True(after.LastBuildSucceeded); |
| 37 | } |
| 38 | } |
| 39 | |