public void GamestateApplyMultiplePlayerPacketsTest() { short actorNumber = 1; GamestateCommitTestHelper <PlayerEntry> testHelper = new GamestateCommitTestHelper <PlayerEntry>(actorNumber); GamestateTable <PlayerEntry> players = testHelper.TestTable(GamestateTracker.Table.Players); GamestateRandomTestingUnit generator = new GamestateRandomTestingUnit(8); for (short i = 0; i < 100; i++) { PlayerEntry playerEntry = players.Create(i); generator.RandomisePlayerEntry(playerEntry); playerEntry.Commit(); GamestatePacket packet = testHelper.commitedPackets[0]; testHelper.Apply(packet); playerEntry = players.Get(i); GamestateAssertionUnit.AssertPacketApplied(playerEntry, packet); generator.RandomisePlayerEntry(playerEntry); playerEntry.Commit(); packet = testHelper.commitedPackets[1]; testHelper.Apply(packet); playerEntry = players.Get(i); GamestateAssertionUnit.AssertPacketApplied(playerEntry, packet); playerEntry.Release(); testHelper.commitedPackets.Clear(); } }
public void GamestateCreateTeamTest() { short id = -100; GamestateCommitTestHelper <TeamEntry> testHelper = new GamestateCommitTestHelper <TeamEntry>(1); GamestateTable <TeamEntry> teams = testHelper.TestTable(GamestateTracker.Table.Teams); TeamEntry teamEntry = teams.Create(id); Assert.That(teamEntry, Is.Not.Null); Assert.That(teamEntry.id, Is.EqualTo(id)); teamEntry.Commit(); testHelper.Apply(testHelper.commitedPackets[0]); Assert.That(teams.Get(id), Is.Not.Null); }
public void GamestateCreatePlayerTest() { short id = 7; GamestateCommitTestHelper <PlayerEntry> testHelper = new GamestateCommitTestHelper <PlayerEntry>(1); GamestateTable <PlayerEntry> players = testHelper.TestTable(GamestateTracker.Table.Players); PlayerEntry playerEntry = players.Create(id); Assert.That(playerEntry, Is.Not.Null); Assert.That(playerEntry.id, Is.EqualTo(id)); playerEntry.Commit(); testHelper.Apply(testHelper.commitedPackets[0]); Assert.That(players.Get(id), Is.Not.Null); }
public void GamestateApplyTeamPacketMultipleErrorCallbacksTest() { short actorNumber = 1; GamestateCommitTestHelper <TeamEntry> testHelper = new GamestateCommitTestHelper <TeamEntry>(actorNumber); GamestateTable <TeamEntry> teams = testHelper.TestTable(GamestateTracker.Table.Teams); GamestateRandomTestingUnit generator = new GamestateRandomTestingUnit(62); for (short i = 0; i < 100; i++) { TeamEntry teamEntry = teams.Create(i); generator.RandomiseTeamEntry(teamEntry); GamestatePacket packet = GamestatePacketManager.GetPacket(); bool errorCallbackACalled = false; bool errorCallbackBCalled = false; teamEntry.Commit((TeamEntry entry, bool succeeded) => { Assert.That(succeeded, Is.EqualTo(true)); GamestateAssertionUnit.AssertPacketApplied(entry, packet); entry.Release(); errorCallbackACalled = true; }); teamEntry = teams.Get(i); teamEntry.Commit((TeamEntry entry, bool succeeded) => { Assert.That(succeeded, Is.EqualTo(false)); GamestateAssertionUnit.AssertPacketApplied(entry, packet); entry.Release(); errorCallbackBCalled = true; }); packet = testHelper.commitedPackets[0]; testHelper.Apply(packet); Assert.That(errorCallbackACalled, Is.EqualTo(true)); Assert.That(errorCallbackBCalled, Is.EqualTo(true)); testHelper.commitedPackets.Clear(); } }
public void GamestateAttemptApplyPlayerPacketTest() { byte actorNumber = 1; GamestateCommitTestHelper <PlayerEntry> testHelper = new GamestateCommitTestHelper <PlayerEntry>(actorNumber); GamestateTable <PlayerEntry> players = testHelper.TestTable(GamestateTracker.Table.Players); GamestateRandomTestingUnit generator = new GamestateRandomTestingUnit(902); for (short i = 0; i < 100; i++) { PlayerEntry playerEntry = players.Create(i); generator.RandomisePlayerEntry(playerEntry); playerEntry.Commit(); GamestatePacket packetA = testHelper.commitedPackets[0]; bool attemptA = testHelper.AttemptApply(packetA); GamestatePacket packetB = generator.GetRandomPacket(); packetB.id = i; packetB.packetType = GamestatePacket.PacketType.Update; packetB.revisionNumber = packetA.revisionNumber; bool attemptB = testHelper.AttemptApply(packetB); GamestatePacket packetC = generator.GetRandomPacket(); packetC.id = i; packetC.packetType = GamestatePacket.PacketType.Update; packetC.revisionNumber = packetA.revisionNumber; bool attemptC = testHelper.AttemptApply(packetC); Assert.That(attemptA, Is.EqualTo(true)); Assert.That(attemptB, Is.EqualTo(false)); Assert.That(attemptC, Is.EqualTo(false)); playerEntry = players.Get(i); GamestateAssertionUnit.AssertPacketApplied(playerEntry, packetA); playerEntry.Release(); testHelper.commitedPackets.Clear(); } }
public void GamestateApplyTeamPacketTest() { short actorNumber = 17; GamestateCommitTestHelper <TeamEntry> testHelper = new GamestateCommitTestHelper <TeamEntry>(actorNumber); GamestateTable <TeamEntry> teams = testHelper.TestTable(GamestateTracker.Table.Teams); GamestateRandomTestingUnit generator = new GamestateRandomTestingUnit(82); for (short i = 0; i < 100; i++) { TeamEntry teamEntry = teams.Create(i); generator.RandomiseTeamEntry(teamEntry); teamEntry.Commit(); GamestatePacket packet = testHelper.commitedPackets[0]; testHelper.Apply(packet); teamEntry = teams.Get(i); GamestateAssertionUnit.AssertPacketApplied(teamEntry, packet); teamEntry.Release(); testHelper.commitedPackets.Clear(); } }