Creator: "even if it's not visible, we want to avoid polling." ScoreboardEnabled is the layer's master switch in the properties panel. Off means two things: - the strip frame is null in every scene (per-scene eye toggles stay independent), and - the cadence policy returns None at every phase — a scoreboard nobody can see must not spend quota. The switch is persisted (Scoreboard.Enabled), because one that resets would quietly resume polling. The polling gate is ScoreboardPollsEnabled: master switch AND at least one scene with a visible scoreboard — so hiding it in all five scenes also stops the polls. Guards: ScoreboardCadenceTests adds the switch off across live/test/recording; ScoreboardProperties pins the checkbox and the VM surface.
45 lines
2.1 KiB
C#
45 lines
2.1 KiB
C#
using System;
|
|
using Xunit;
|
|
using ytLive.Models;
|
|
|
|
namespace ytLive.Tests;
|
|
|
|
/// <summary>The quiet-by-default rule: watch hours only during a live stream (Analytics is a daily
|
|
/// figure and test/record sessions have no public audience), subscribers whenever the app is
|
|
/// working, and silence when idle.</summary>
|
|
public class ScoreboardCadenceTests
|
|
{
|
|
[Fact]
|
|
public void Analytics_polls_only_when_live_and_subscribers_poll_during_any_session()
|
|
{
|
|
var now = new DateTime(2026, 10, 30, 12, 0, 0, DateTimeKind.Utc);
|
|
var old = now.AddHours(-2);
|
|
|
|
// Idle: silent, even if everything is stale.
|
|
Assert.Equal(ScoreboardPoll.None, ScoreboardCadence.Due(SessionPhase.Idle, old, old, now));
|
|
|
|
// Live with stale figures: both.
|
|
Assert.Equal(ScoreboardPoll.Both, ScoreboardCadence.Due(SessionPhase.Live, old, old, now));
|
|
|
|
// Test / recording: subscribers only — no public audience, so no analytics.
|
|
Assert.Equal(ScoreboardPoll.SubscribersOnly, ScoreboardCadence.Due(SessionPhase.Test, old, old, now));
|
|
Assert.Equal(ScoreboardPoll.SubscribersOnly, ScoreboardCadence.Due(SessionPhase.Recording, old, old, now));
|
|
|
|
// Fresh figures: nothing is due.
|
|
Assert.Equal(ScoreboardPoll.None, ScoreboardCadence.Due(SessionPhase.Live, now, now, now));
|
|
|
|
// Analytics alone never polls (it is not a kind the poller knows).
|
|
Assert.Equal(ScoreboardPoll.None,
|
|
ScoreboardCadence.Due(SessionPhase.Live, old, now.AddSeconds(-10), now));
|
|
|
|
// The master switch beats every other rule: off means silent, whatever the session is.
|
|
Assert.Equal(ScoreboardPoll.None, ScoreboardCadence.Due(SessionPhase.Live, old, old, now, enabled: false));
|
|
Assert.Equal(ScoreboardPoll.None, ScoreboardCadence.Due(SessionPhase.Test, old, old, now, enabled: false));
|
|
Assert.Equal(ScoreboardPoll.None, ScoreboardCadence.Due(SessionPhase.Recording, old, old, now, enabled: false));
|
|
|
|
// Subscribers alone mid-window.
|
|
Assert.Equal(ScoreboardPoll.SubscribersOnly,
|
|
ScoreboardCadence.Due(SessionPhase.Live, now, old, now));
|
|
}
|
|
}
|