Tests: don't need to inherit from SyncList<T> anymore

This commit is contained in:
vis2k 2021-09-17 14:53:02 +08:00
parent ccb901e708
commit 76ebb86d6d
2 changed files with 18 additions and 22 deletions

View File

@ -7,10 +7,8 @@ namespace Mirror.Tests
[TestFixture]
public class SyncDictionaryTest
{
public class SyncDictionaryIntString : SyncDictionary<int, string> {}
SyncDictionaryIntString serverSyncDictionary;
SyncDictionaryIntString clientSyncDictionary;
SyncDictionary<int, string> serverSyncDictionary;
SyncDictionary<int, string> clientSyncDictionary;
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]
public void SetUp()
{
serverSyncDictionary = new SyncDictionaryIntString();
clientSyncDictionary = new SyncDictionaryIntString();
serverSyncDictionary = new SyncDictionary<int, string>();
clientSyncDictionary = new SyncDictionary<int, string>();
// add some data to the list
serverSyncDictionary.Add(0, "Hello");
@ -69,7 +67,7 @@ public void TestClear()
{
serverSyncDictionary.Clear();
SerializeDeltaTo(serverSyncDictionary, clientSyncDictionary);
Assert.That(serverSyncDictionary, Is.EquivalentTo(new SyncDictionaryIntString()));
Assert.That(serverSyncDictionary, Is.EquivalentTo(new SyncDictionary<int, string>()));
}
[Test]
@ -156,7 +154,7 @@ public void CallbackTest()
{
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(item, Is.EqualTo("yay"));
Assert.That(clientSyncDictionary[index], Is.EqualTo("yay"));
@ -175,7 +173,7 @@ public void ServerCallbackTest()
{
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(item, Is.EqualTo("yay"));
Assert.That(serverSyncDictionary[index], Is.EqualTo("yay"));
@ -191,7 +189,7 @@ public void CallbackRemoveTest()
clientSyncDictionary.Callback += (op, key, item) =>
{
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"));
};
serverSyncDictionary.Remove(1);
@ -294,8 +292,8 @@ public void ObjectCanBeReusedAfterReset()
clientSyncDictionary.Reset();
// make old client the host
SyncDictionaryIntString hostList = clientSyncDictionary;
SyncDictionaryIntString clientList2 = new SyncDictionaryIntString();
SyncDictionary<int, string> hostList = clientSyncDictionary;
SyncDictionary<int, string> clientList2 = new SyncDictionary<int, string>();
Assert.That(hostList.IsReadOnly, Is.False);

View File

@ -7,10 +7,8 @@ namespace Mirror.Tests
[TestFixture]
public class SyncSetTest
{
public class SyncSetString : SyncHashSet<string> {}
SyncSetString serverSyncSet;
SyncSetString clientSyncSet;
SyncHashSet<string> serverSyncSet;
SyncHashSet<string> clientSyncSet;
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]
public void SetUp()
{
serverSyncSet = new SyncSetString();
clientSyncSet = new SyncSetString();
serverSyncSet = new SyncHashSet<string>();
clientSyncSet = new SyncHashSet<string>();
// add some data to the list
serverSyncSet.Add("Hello");
@ -99,7 +97,7 @@ public void CallbackTest()
{
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"));
};
@ -118,7 +116,7 @@ public void CallbackRemoveTest()
{
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"));
};
serverSyncSet.Remove("World");
@ -263,8 +261,8 @@ public void ObjectCanBeReusedAfterReset()
clientSyncSet.Reset();
// make old client the host
SyncSetString hostList = clientSyncSet;
SyncSetString clientList2 = new SyncSetString();
SyncHashSet<string> hostList = clientSyncSet;
SyncHashSet<string> clientList2 = new SyncHashSet<string>();
Assert.That(hostList.IsReadOnly, Is.False);