Music never falls silent (TrackPicker); mod unit tests

This commit is contained in:
cthangover committed 2026-10-21 12:31:46 +02:00
1 parent eefa7058c6
commit 41a854ef36
5 files changed
+100 -54

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
namespace Cthangover.Mods.Audio.Tests
{
using System;
using System.Collections.Generic;
using Cthangover.Core.Mods.Testing;
/// <summary>
/// Choosing the next track never fails: it avoids repeating the last one
/// when anything else is available, and a bucket made of one track (or of
/// copies of it) still plays instead of falling silent.
/// </summary>
public class TrackPickerTests
{
[ModTest("music/next_track_avoids_repeat_and_never_gives_up")]
static void NextTrackAvoidsRepeat(ModTestContext ctx)
{
var random = new Random(3);
var list = new List<string> { "a", "b" };
for (var i = 0; i < 200; i++)
ModAssert.Equal("b", TrackPicker.Next(list, "a", random), "the other track");
ModAssert.Equal("a", TrackPicker.Next(new List<string> { "a", "a", "a" }, "a", random), "copies of one track still play");
ModAssert.Equal("a", TrackPicker.Next(new List<string> { "a" }, "a", random), "a single track repeats");
ModAssert.Null(TrackPicker.Next(new List<string>(), "a", random), "an empty bucket gives nothing");
}
}
}