Files
SVSimServer/SVSim.UnitTests/Database/Config/ColosseumRoundsConfigTests.cs
gamer147 110867358c feat(arena-colosseum): lobby + constructed entry (phase 1)
Closes 5 of arena-colosseum's 16 spec shapes (1/16 → 6/16). Lobby reads
(/top, /get_fee_info, /event_info) render an empty "no event scheduled"
payload by default; /entry + /register_deck activate via admin-flipped
ColosseumSeason + ColosseumRounds config sections.

* Schema: ViewerArenaColosseumRun standalone table (unique on ViewerId)
  with jsonb run-state columns mirroring ViewerArenaTwoPickRun.
* Config sections: ColosseumSeasonConfig (event-level), ColosseumRoundsConfig
  (the 3-round bracket). Empty defaults — IsColosseumPeriod=false.
* Migration AddArenaColosseumRun (DDL only; seed rows come from the section
  ShippedDefaults via EnsureSeedDataAsync).
* DTOs: ColosseumLobbyInfo (round-level, /top + /get_fee_info), ColosseumEventInfo
  (event-level, /event_info), ColosseumOwnStatus (shared status block),
  ColosseumEntryRef, ColosseumFeeList, ColosseumUserDeck, ColosseumBattleResults,
  ColosseumRoundDetail + ColosseumGroupRow. EventInfoResponse uses explicit
  [JsonPropertyName("1"|"2"|"3")] for the string-keyed rounds shape per spec.
* Controller: ArenaColosseumController replaces the 1-action stub with
  the five lifecycle endpoints. /top emits leader_skin_id even when 0
  (project_wire_null_policy override).
* Tests: 11 controller-level tests + 6 config round-trip tests covering
  empty-season payloads, run-seeded /top round-trip, crystal/rupy entry
  debits, now_round_id mismatch rejection, deck_no_list round-trip + reject.
2026-06-13 12:16:22 -04:00

47 lines
1.5 KiB
C#

using System.Linq;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;
using SVSim.Database;
using SVSim.Database.Models.Config;
using SVSim.EmulatedEntrypoint.Services;
using SVSim.UnitTests.Infrastructure;
namespace SVSim.UnitTests.Database.Config;
[TestFixture]
public class ColosseumRoundsConfigTests
{
[Test]
public void ShippedDefaults_emits_empty_rounds()
{
var cfg = ColosseumRoundsConfig.ShippedDefaults();
Assert.That(cfg.Rounds, Is.Empty,
"default ship state has no rounds — /event_info renders a benign empty payload");
}
[Test]
public void Has_ConfigSection_attribute_with_name_ColosseumRounds()
{
var attr = typeof(ColosseumRoundsConfig)
.GetCustomAttributes(typeof(ConfigSectionAttribute), false)
.Cast<ConfigSectionAttribute>()
.FirstOrDefault();
Assert.That(attr, Is.Not.Null);
Assert.That(attr!.Name, Is.EqualTo("ColosseumRounds"));
}
[Test]
public void Get_through_GameConfigService_round_trips_shipped_defaults()
{
using var factory = new SVSimTestFactory();
using var scope = factory.Services.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SVSimDbContext>();
var svc = new GameConfigService(db, new ConfigurationBuilder().Build());
var cfg = svc.Get<ColosseumRoundsConfig>();
Assert.That(cfg.Rounds, Is.Empty);
}
}