mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 19:10:32 +00:00
chore(SyncDictionaryTest): Improved tests
This commit is contained in:
parent
0b8b11e78f
commit
05d68f91af
@ -79,6 +79,7 @@ public void CurlyBracesConstructor()
|
||||
[Test]
|
||||
public void TestAdd()
|
||||
{
|
||||
// Adds a new entry with index of 4 using .Add method
|
||||
serverSyncDictionary.Add(4, "yay");
|
||||
SerializeDeltaTo(serverSyncDictionary, clientSyncDictionary);
|
||||
Assert.That(clientSyncDictionary.ContainsKey(4));
|
||||
@ -96,19 +97,45 @@ public void TestClear()
|
||||
[Test]
|
||||
public void TestSet()
|
||||
{
|
||||
// Overwrites an existing entry
|
||||
bool called = false;
|
||||
clientSyncDictionary.Callback = (op, index, item) =>
|
||||
{
|
||||
called = true;
|
||||
|
||||
Assert.That(op, Is.EqualTo(SyncDictionary<int, string>.Operation.OP_SET));
|
||||
Assert.That(index, Is.EqualTo(1));
|
||||
Assert.That(item, Is.EqualTo("yay"));
|
||||
Assert.That(clientSyncDictionary[index], Is.EqualTo("yay"));
|
||||
|
||||
};
|
||||
serverSyncDictionary[1] = "yay";
|
||||
SerializeDeltaTo(serverSyncDictionary, clientSyncDictionary);
|
||||
Assert.That(clientSyncDictionary.ContainsKey(1));
|
||||
Assert.That(clientSyncDictionary[1], Is.EqualTo("yay"));
|
||||
Assert.That(called, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBareSet()
|
||||
{
|
||||
// Adds a new entry with index of 4 without using .Add method
|
||||
bool called = false;
|
||||
clientSyncDictionary.Callback = (op, index, item) =>
|
||||
{
|
||||
called = true;
|
||||
|
||||
Assert.That(op, Is.EqualTo(SyncDictionary<int, string>.Operation.OP_ADD));
|
||||
Assert.That(index, Is.EqualTo(4));
|
||||
Assert.That(item, Is.EqualTo("yay"));
|
||||
Assert.That(clientSyncDictionary[index], Is.EqualTo("yay"));
|
||||
|
||||
};
|
||||
serverSyncDictionary[4] = "yay";
|
||||
SerializeDeltaTo(serverSyncDictionary, clientSyncDictionary);
|
||||
Assert.That(clientSyncDictionary.ContainsKey(4));
|
||||
Assert.That(clientSyncDictionary[4], Is.EqualTo("yay"));
|
||||
Assert.That(called, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -173,7 +200,7 @@ public void TestContains()
|
||||
public void CallbackTest()
|
||||
{
|
||||
bool called = false;
|
||||
clientSyncDictionary.Callback += (op, index, item) =>
|
||||
clientSyncDictionary.Callback = (op, index, item) =>
|
||||
{
|
||||
called = true;
|
||||
|
||||
@ -192,7 +219,7 @@ public void CallbackTest()
|
||||
public void ServerCallbackTest()
|
||||
{
|
||||
bool called = false;
|
||||
serverSyncDictionary.Callback += (op, index, item) =>
|
||||
serverSyncDictionary.Callback = (op, index, item) =>
|
||||
{
|
||||
called = true;
|
||||
|
||||
@ -209,7 +236,7 @@ public void ServerCallbackTest()
|
||||
public void CallbackRemoveTest()
|
||||
{
|
||||
bool called = false;
|
||||
clientSyncDictionary.Callback += (op, key, item) =>
|
||||
clientSyncDictionary.Callback = (op, key, item) =>
|
||||
{
|
||||
called = true;
|
||||
Assert.That(op, Is.EqualTo(SyncDictionary<int, string>.Operation.OP_REMOVE));
|
||||
|
Loading…
Reference in New Issue
Block a user