SyncVarTest: reuse CreateNetworked

This commit is contained in:
vis2k 2021-05-20 15:56:54 +08:00
parent f846b311f3
commit 8961eb2ec6

View File

@ -41,9 +41,7 @@ public class SyncVarTest : SyncVarTestBase
[Test]
public void TestSettingStruct()
{
GameObject gameObject = new GameObject();
MockPlayer player = gameObject.AddComponent<MockPlayer>();
CreateNetworked(out GameObject gameObject, out NetworkIdentity identity, out MockPlayer player);
// synchronize immediately
player.syncInterval = 0f;
@ -69,9 +67,7 @@ public void TestSettingStruct()
[Test]
public void TestSyncIntervalAndClearDirtyComponents()
{
GameObject gameObject = new GameObject();
MockPlayer player = gameObject.AddComponent<MockPlayer>();
CreateNetworked(out GameObject gameObject, out NetworkIdentity identity, out MockPlayer player);
player.lastSyncTime = Time.time;
// synchronize immediately
player.syncInterval = 1f;
@ -97,9 +93,7 @@ public void TestSyncIntervalAndClearDirtyComponents()
[Test]
public void TestSyncIntervalAndClearAllComponents()
{
GameObject gameObject = new GameObject();
MockPlayer player = gameObject.AddComponent<MockPlayer>();
CreateNetworked(out GameObject gameObject, out NetworkIdentity identity, out MockPlayer player);
player.lastSyncTime = Time.time;
// synchronize immediately
player.syncInterval = 1f;
@ -126,9 +120,7 @@ public void TestSyncIntervalAndClearAllComponents()
public void TestSynchronizingObjects()
{
// set up a "server" object
GameObject gameObject1 = new GameObject();
NetworkIdentity identity1 = gameObject1.AddComponent<NetworkIdentity>();
MockPlayer player1 = gameObject1.AddComponent<MockPlayer>();
CreateNetworked(out GameObject gameObject1, out NetworkIdentity identity1, out MockPlayer player1);
MockPlayer.Guild myGuild = new MockPlayer.Guild
{
name = "Back street boys"
@ -142,9 +134,7 @@ public void TestSynchronizingObjects()
identity1.OnSerializeAllSafely(true, ownerWriter, out int ownerWritten, observersWriter, out int observersWritten);
// set up a "client" object
GameObject gameObject2 = new GameObject();
NetworkIdentity identity2 = gameObject2.AddComponent<NetworkIdentity>();
MockPlayer player2 = gameObject2.AddComponent<MockPlayer>();
CreateNetworked(out GameObject gameObject2, out NetworkIdentity identity2, out MockPlayer player2);
// apply all the data from the server object
NetworkReader reader = new NetworkReader(ownerWriter.ToArray());