Files
LlamaCasty/ytLive.Tests/SessionStartDecisionTests.cs
T
gramps 0f8647790d fix(top bar): a signed-out ON-AIR press starts sign-in instead of disabling the button
Reported: EDIT on + ON-AIR on, signed out → the button reads "Test Stream" and cannot be pressed.
Cause: the primary button bound straight to StartTestCommand, whose CanExecute needs a connection.
StartSession already routed signed-out ON-AIR to the sign-in flow; the test path bypassed it.

The route is now explicit and pure: RouteFor(kind, connected) → SignIn | Record | Live | Test. The
primary command calls SignInAsync for the SignIn route, BeginTestStream for Test, StartSession
otherwise — so the label, the action and the sign-in fallback cannot drift apart. Pinned in
SessionStartDecisionTests for both live and test, connected and not.
2026-10-30 11:17:11 -07:00

41 lines
2.3 KiB
C#

using Xunit;
using ytLive.Models;
namespace ytLive.Tests;
/// <summary>Creator ruling (2026-10-30): the top bar's primary button is context-sensitive and the
/// separate TEST button is gone.
///
/// <para>EDIT off + ON-AIR → the livestream message. EDIT on + ON-AIR → the test-livestream
/// message. REC always records, because there is no test recording. The matrix is pure, so it is
/// cheaper to pin it here than to drive a window.</para></summary>
public class SessionStartDecisionTests
{
[Fact]
public void Edit_decides_whether_the_on_air_start_is_live_or_a_test()
{
// ON-AIR armed: EDIT decides.
Assert.Equal(SessionStartKind.Live, SessionStartDecision.For(recordArmed: false, onAirArmed: true, editing: false));
Assert.Equal("Go Live", SessionStartDecision.LabelFor(SessionStartKind.Live));
Assert.Equal(SessionStartKind.Test, SessionStartDecision.For(recordArmed: false, onAirArmed: true, editing: true));
Assert.Equal("Test Stream", SessionStartDecision.LabelFor(SessionStartKind.Test));
// REC armed: always a recording, whatever EDIT says (no test recording exists).
Assert.Equal(SessionStartKind.Record, SessionStartDecision.For(true, false, false));
Assert.Equal(SessionStartKind.Record, SessionStartDecision.For(true, false, true));
Assert.Equal("Start Recording", SessionStartDecision.LabelFor(SessionStartKind.Record));
// Signed out: an ON-AIR press (live OR test) routes to the sign-in flow, never a dead
// button. Recording never needs an account.
Assert.Equal(SessionStartDecision.Route.SignIn, SessionStartDecision.RouteFor(SessionStartKind.Live, connected: false));
Assert.Equal(SessionStartDecision.Route.SignIn, SessionStartDecision.RouteFor(SessionStartKind.Test, connected: false));
Assert.Equal(SessionStartDecision.Route.Live, SessionStartDecision.RouteFor(SessionStartKind.Live, connected: true));
Assert.Equal(SessionStartDecision.Route.Test, SessionStartDecision.RouteFor(SessionStartKind.Test, connected: true));
Assert.Equal(SessionStartDecision.Route.Record, SessionStartDecision.RouteFor(SessionStartKind.Record, connected: false));
// Unarmed start records locally (the no-dead-ends rule).
Assert.Equal(SessionStartKind.Record, SessionStartDecision.For(false, false, false));
}
}