mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Tests: don't need to inherit from SyncList<T> anymore
This commit is contained in:
parent
ccb901e708
commit
76ebb86d6d
@ -7,10 +7,8 @@ namespace Mirror.Tests
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class SyncDictionaryTest
|
public class SyncDictionaryTest
|
||||||
{
|
{
|
||||||
public class SyncDictionaryIntString : SyncDictionary<int, string> {}
|
SyncDictionary<int, string> serverSyncDictionary;
|
||||||
|
SyncDictionary<int, string> clientSyncDictionary;
|
||||||
SyncDictionaryIntString serverSyncDictionary;
|
|
||||||
SyncDictionaryIntString clientSyncDictionary;
|
|
||||||
|
|
||||||
void SerializeAllTo<T>(T fromList, T toList) where T : SyncObject
|
void SerializeAllTo<T>(T fromList, T toList) where T : SyncObject
|
||||||
{
|
{
|
||||||
@ -32,8 +30,8 @@ void SerializeDeltaTo<T>(T fromList, T toList) where T : SyncObject
|
|||||||
[SetUp]
|
[SetUp]
|
||||||
public void SetUp()
|
public void SetUp()
|
||||||
{
|
{
|
||||||
serverSyncDictionary = new SyncDictionaryIntString();
|
serverSyncDictionary = new SyncDictionary<int, string>();
|
||||||
clientSyncDictionary = new SyncDictionaryIntString();
|
clientSyncDictionary = new SyncDictionary<int, string>();
|
||||||
|
|
||||||
// add some data to the list
|
// add some data to the list
|
||||||
serverSyncDictionary.Add(0, "Hello");
|
serverSyncDictionary.Add(0, "Hello");
|
||||||
@ -69,7 +67,7 @@ public void TestClear()
|
|||||||
{
|
{
|
||||||
serverSyncDictionary.Clear();
|
serverSyncDictionary.Clear();
|
||||||
SerializeDeltaTo(serverSyncDictionary, clientSyncDictionary);
|
SerializeDeltaTo(serverSyncDictionary, clientSyncDictionary);
|
||||||
Assert.That(serverSyncDictionary, Is.EquivalentTo(new SyncDictionaryIntString()));
|
Assert.That(serverSyncDictionary, Is.EquivalentTo(new SyncDictionary<int, string>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -156,7 +154,7 @@ public void CallbackTest()
|
|||||||
{
|
{
|
||||||
called = true;
|
called = true;
|
||||||
|
|
||||||
Assert.That(op, Is.EqualTo(SyncDictionaryIntString.Operation.OP_ADD));
|
Assert.That(op, Is.EqualTo(SyncDictionary<int, string>.Operation.OP_ADD));
|
||||||
Assert.That(index, Is.EqualTo(3));
|
Assert.That(index, Is.EqualTo(3));
|
||||||
Assert.That(item, Is.EqualTo("yay"));
|
Assert.That(item, Is.EqualTo("yay"));
|
||||||
Assert.That(clientSyncDictionary[index], Is.EqualTo("yay"));
|
Assert.That(clientSyncDictionary[index], Is.EqualTo("yay"));
|
||||||
@ -175,7 +173,7 @@ public void ServerCallbackTest()
|
|||||||
{
|
{
|
||||||
called = true;
|
called = true;
|
||||||
|
|
||||||
Assert.That(op, Is.EqualTo(SyncDictionaryIntString.Operation.OP_ADD));
|
Assert.That(op, Is.EqualTo(SyncDictionary<int, string>.Operation.OP_ADD));
|
||||||
Assert.That(index, Is.EqualTo(3));
|
Assert.That(index, Is.EqualTo(3));
|
||||||
Assert.That(item, Is.EqualTo("yay"));
|
Assert.That(item, Is.EqualTo("yay"));
|
||||||
Assert.That(serverSyncDictionary[index], Is.EqualTo("yay"));
|
Assert.That(serverSyncDictionary[index], Is.EqualTo("yay"));
|
||||||
@ -191,7 +189,7 @@ public void CallbackRemoveTest()
|
|||||||
clientSyncDictionary.Callback += (op, key, item) =>
|
clientSyncDictionary.Callback += (op, key, item) =>
|
||||||
{
|
{
|
||||||
called = true;
|
called = true;
|
||||||
Assert.That(op, Is.EqualTo(SyncDictionaryIntString.Operation.OP_REMOVE));
|
Assert.That(op, Is.EqualTo(SyncDictionary<int, string>.Operation.OP_REMOVE));
|
||||||
Assert.That(item, Is.EqualTo("World"));
|
Assert.That(item, Is.EqualTo("World"));
|
||||||
};
|
};
|
||||||
serverSyncDictionary.Remove(1);
|
serverSyncDictionary.Remove(1);
|
||||||
@ -294,8 +292,8 @@ public void ObjectCanBeReusedAfterReset()
|
|||||||
clientSyncDictionary.Reset();
|
clientSyncDictionary.Reset();
|
||||||
|
|
||||||
// make old client the host
|
// make old client the host
|
||||||
SyncDictionaryIntString hostList = clientSyncDictionary;
|
SyncDictionary<int, string> hostList = clientSyncDictionary;
|
||||||
SyncDictionaryIntString clientList2 = new SyncDictionaryIntString();
|
SyncDictionary<int, string> clientList2 = new SyncDictionary<int, string>();
|
||||||
|
|
||||||
Assert.That(hostList.IsReadOnly, Is.False);
|
Assert.That(hostList.IsReadOnly, Is.False);
|
||||||
|
|
||||||
|
@ -7,10 +7,8 @@ namespace Mirror.Tests
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class SyncSetTest
|
public class SyncSetTest
|
||||||
{
|
{
|
||||||
public class SyncSetString : SyncHashSet<string> {}
|
SyncHashSet<string> serverSyncSet;
|
||||||
|
SyncHashSet<string> clientSyncSet;
|
||||||
SyncSetString serverSyncSet;
|
|
||||||
SyncSetString clientSyncSet;
|
|
||||||
|
|
||||||
void SerializeAllTo<T>(T fromList, T toList) where T : SyncObject
|
void SerializeAllTo<T>(T fromList, T toList) where T : SyncObject
|
||||||
{
|
{
|
||||||
@ -32,8 +30,8 @@ void SerializeDeltaTo<T>(T fromList, T toList) where T : SyncObject
|
|||||||
[SetUp]
|
[SetUp]
|
||||||
public void SetUp()
|
public void SetUp()
|
||||||
{
|
{
|
||||||
serverSyncSet = new SyncSetString();
|
serverSyncSet = new SyncHashSet<string>();
|
||||||
clientSyncSet = new SyncSetString();
|
clientSyncSet = new SyncHashSet<string>();
|
||||||
|
|
||||||
// add some data to the list
|
// add some data to the list
|
||||||
serverSyncSet.Add("Hello");
|
serverSyncSet.Add("Hello");
|
||||||
@ -99,7 +97,7 @@ public void CallbackTest()
|
|||||||
{
|
{
|
||||||
called = true;
|
called = true;
|
||||||
|
|
||||||
Assert.That(op, Is.EqualTo(SyncSetString.Operation.OP_ADD));
|
Assert.That(op, Is.EqualTo(SyncHashSet<string>.Operation.OP_ADD));
|
||||||
Assert.That(item, Is.EqualTo("yay"));
|
Assert.That(item, Is.EqualTo("yay"));
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -118,7 +116,7 @@ public void CallbackRemoveTest()
|
|||||||
{
|
{
|
||||||
called = true;
|
called = true;
|
||||||
|
|
||||||
Assert.That(op, Is.EqualTo(SyncSetString.Operation.OP_REMOVE));
|
Assert.That(op, Is.EqualTo(SyncHashSet<string>.Operation.OP_REMOVE));
|
||||||
Assert.That(item, Is.EqualTo("World"));
|
Assert.That(item, Is.EqualTo("World"));
|
||||||
};
|
};
|
||||||
serverSyncSet.Remove("World");
|
serverSyncSet.Remove("World");
|
||||||
@ -263,8 +261,8 @@ public void ObjectCanBeReusedAfterReset()
|
|||||||
clientSyncSet.Reset();
|
clientSyncSet.Reset();
|
||||||
|
|
||||||
// make old client the host
|
// make old client the host
|
||||||
SyncSetString hostList = clientSyncSet;
|
SyncHashSet<string> hostList = clientSyncSet;
|
||||||
SyncSetString clientList2 = new SyncSetString();
|
SyncHashSet<string> clientList2 = new SyncHashSet<string>();
|
||||||
|
|
||||||
Assert.That(hostList.IsReadOnly, Is.False);
|
Assert.That(hostList.IsReadOnly, Is.False);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user