44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using NUnit.Framework;
|
|
using SVSim.BattleNode.Sessions;
|
|
|
|
namespace SVSim.UnitTests.BattleNode.Sessions;
|
|
|
|
[TestFixture]
|
|
public class InMemoryBattleSessionStoreTests
|
|
{
|
|
private InMemoryBattleSessionStore _store = null!;
|
|
|
|
[SetUp] public void Setup() => _store = new InMemoryBattleSessionStore();
|
|
|
|
[Test]
|
|
public void RegisterThenGet_ReturnsRegisteredBattle()
|
|
{
|
|
var battle = new PendingBattle("bid-1", 906243102);
|
|
_store.RegisterPending(battle);
|
|
|
|
Assert.That(_store.TryGetPending("bid-1"), Is.EqualTo(battle));
|
|
}
|
|
|
|
[Test]
|
|
public void Get_UnknownBattleId_ReturnsNull()
|
|
{
|
|
Assert.That(_store.TryGetPending("nope"), Is.Null);
|
|
}
|
|
|
|
[Test]
|
|
public void Remove_ReturnsTrueWhenPresent_FalseWhenAbsent()
|
|
{
|
|
_store.RegisterPending(new PendingBattle("bid", 1));
|
|
Assert.That(_store.RemovePending("bid"), Is.True);
|
|
Assert.That(_store.RemovePending("bid"), Is.False);
|
|
}
|
|
|
|
[Test]
|
|
public void Register_DuplicateBattleId_OverwritesPrior()
|
|
{
|
|
_store.RegisterPending(new PendingBattle("bid", 1));
|
|
_store.RegisterPending(new PendingBattle("bid", 2));
|
|
Assert.That(_store.TryGetPending("bid")!.ViewerId, Is.EqualTo(2));
|
|
}
|
|
}
|