feat(arena-tk2): do_matching mints battle via IMatchingBridge, returns 3004

This commit is contained in:
gamer147
2026-05-31 22:53:20 -04:00
parent 88ed8254af
commit ff51c33b6c
3 changed files with 34 additions and 12 deletions

View File

@@ -1,5 +1,6 @@
using System.Net;
using System.Net.Http.Json;
using System.Text.Json;
using SVSim.UnitTests.Infrastructure;
namespace SVSim.UnitTests.Controllers;
@@ -7,7 +8,7 @@ namespace SVSim.UnitTests.Controllers;
public class ArenaTwoPickBattleControllerTests
{
[Test]
public async Task DoMatching_returns_perpetual_searching_with_empty_node_url()
public async Task DoMatching_AuthenticatedViewer_Returns3004WithBattleIdAndNodeUrl()
{
using var factory = new SVSimTestFactory();
var viewerId = await factory.SeedViewerAsync();
@@ -20,8 +21,13 @@ public class ArenaTwoPickBattleControllerTests
Assert.That(resp.StatusCode, Is.EqualTo(HttpStatusCode.OK));
var body = await resp.Content.ReadAsStringAsync();
StringAssert.Contains("\"matching_state\":3002", body);
StringAssert.Contains("\"node_server_url\":\"\"", body);
StringAssert.DoesNotContain("\"battle_id\"", body);
using var doc = JsonDocument.Parse(body);
var root = doc.RootElement;
Assert.That(root.GetProperty("matching_state").GetInt32(), Is.EqualTo(3004));
var battleId = root.GetProperty("battle_id").GetString();
Assert.That(battleId, Is.Not.Null.And.Not.Empty);
var nodeUrl = root.GetProperty("node_server_url").GetString();
Assert.That(nodeUrl, Does.StartWith("ws://"));
}
}