-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathPlayerMappingTest.cs
More file actions
63 lines (51 loc) · 1.85 KB
/
PlayerMappingTest.cs
File metadata and controls
63 lines (51 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using Bridge.State;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace RLBotCSTests;
[TestClass]
public class PlayerMappingTest
{
private PlayerMapping? _playerMapping;
[TestInitialize]
public void Init()
{
_playerMapping = new PlayerMapping();
}
[TestMethod]
public void TestSpawnProcess()
{
int playerId = 2398249;
string agentId = "dev/abot";
uint desiredIndex = 2;
ushort actorId = 2398;
ushort commandId = 9855;
var spawnTracker = new SpawnTracker()
{
PlayerId = playerId,
AgentId = agentId,
CommandId = commandId,
DesiredPlayerIndex = desiredIndex,
IsBot = true,
};
// add pending spawn
_playerMapping!.AddPendingSpawn(spawnTracker);
// apply car spawn from known player
var metadata = _playerMapping.ApplyCarSpawn(actorId, commandId);
Assert.AreEqual(desiredIndex, _playerMapping.PlayerIndexFromActorId(actorId));
Assert.AreEqual(playerId, metadata.PlayerId);
Assert.AreEqual(agentId, metadata.AgentId);
Assert.IsTrue(metadata.IsBot);
Assert.IsFalse(metadata.IsCustomBot);
// apply car spawn from unknown player
var metadata2 = _playerMapping.ApplyCarSpawn(111, 222);
uint? index = _playerMapping.PlayerIndexFromActorId(111);
Assert.AreEqual(0u, _playerMapping.PlayerIndexFromActorId(111));
Assert.IsNotNull(index);
Assert.AreEqual(0u, index);
Assert.AreNotEqual(0, metadata2.PlayerId);
Assert.AreEqual(desiredIndex, _playerMapping.PlayerIndexFromActorId(actorId));
Assert.IsFalse(metadata2.IsBot);
Assert.IsFalse(metadata2.IsCustomBot);
uint? index2 = _playerMapping.PlayerIndexFromActorId(456);
Assert.IsNull(index2);
}
}