Skip to content

Commit

Permalink
fix: compilation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpach committed Mar 9, 2020
1 parent c54227b commit 22bf925
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 27 deletions.
11 changes: 0 additions & 11 deletions Assets/Mirror/Tests/Editor/NetworkClientTests.cs.meta

This file was deleted.

16 changes: 14 additions & 2 deletions Assets/Mirror/Tests/Play/ClientServerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void SetupServer()
manager.StartServer();
}

public void SetupClient()
public void SetupClient(string hostname = "localhost")
{
clientNetworkManagerGo = new GameObject();
clientManager = clientNetworkManagerGo.AddComponent<NetworkManager>();
Expand All @@ -38,7 +38,19 @@ public void SetupClient()
server2 = clientManager.server;
client2 = clientManager.client;

clientManager.StartClient("localhost");
clientManager.StartClient(hostname);
}

public void SetupClient(System.Uri uri)
{
clientNetworkManagerGo = new GameObject();
clientManager = clientNetworkManagerGo.AddComponent<NetworkManager>();
clientManager.client = clientNetworkManagerGo.GetComponent<NetworkClient>();
clientManager.server = clientNetworkManagerGo.GetComponent<NetworkServer>();
server2 = clientManager.server;
client2 = clientManager.client;

clientManager.StartClient(uri);
}

public void ShutdownServer()
Expand Down
38 changes: 24 additions & 14 deletions Assets/Mirror/Tests/Play/NetworkBehaviourTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ namespace Mirror.Tests
{
public class EmptyBehaviour : NetworkBehaviour
{
public bool SyncVarGameObjectEqualExposed(GameObject newGameObject, uint netIdField)
{
return SyncVarGameObjectEqual(newGameObject, netIdField);
}

public bool SyncVarNetworkIdentityEqualExposed(NetworkIdentity ni, uint netIdField)
{
return SyncVarNetworkIdentityEqual(ni, netIdField);
}

}

// we need to inherit from networkbehaviour to test protected functions
Expand Down Expand Up @@ -166,7 +176,7 @@ public void SyncVarGameObjectEqualZeroNetIdNullIsTrue()
// better to return false here.
// => we possibly return false so that resync doesn't happen when
// GO disappears? or not?
bool result = component.SyncVarGameObjectEqual(null, 0);
bool result = component.SyncVarGameObjectEqualExposed(null, 0);
Assert.That(result, Is.True);
}

Expand All @@ -178,7 +188,7 @@ public void SyncVarGameObjectEqualNull()
identity.netId = 42;

// null should return false
bool result = component.SyncVarGameObjectEqual(null, identity.netId);
bool result = component.SyncVarGameObjectEqualExposed(null, identity.netId);
Assert.That(result, Is.False);
}

Expand All @@ -193,7 +203,7 @@ public void SyncVarGameObjectEqualZeroNetIdAndGOWithoutIdentityComponentIsTrue()
// => we possibly return false so that resync doesn't happen when
// GO disappears? or not?
GameObject go = new GameObject();
bool result = component.SyncVarGameObjectEqual(go, 0);
bool result = component.SyncVarGameObjectEqualExposed(go, 0);
Assert.That(result, Is.True);
}

Expand All @@ -206,7 +216,7 @@ public void SyncVarGameObjectEqualWithoutIdentityComponent()

// gameobject without networkidentity component should return false
GameObject go = new GameObject();
bool result = component.SyncVarGameObjectEqual(go, identity.netId);
bool result = component.SyncVarGameObjectEqualExposed(go, identity.netId);
Assert.That(result, Is.False);

// clean up
Expand All @@ -224,7 +234,7 @@ public void SyncVarGameObjectEqualValidGOWithDifferentNetId()
GameObject go = new GameObject();
NetworkIdentity ni = go.AddComponent<NetworkIdentity>();
ni.netId = 43;
bool result = component.SyncVarGameObjectEqual(go, identity.netId);
bool result = component.SyncVarGameObjectEqualExposed(go, identity.netId);
Assert.That(result, Is.False);

// clean up
Expand All @@ -242,7 +252,7 @@ public void SyncVarGameObjectEqualValidGOWithSameNetId()
GameObject go = new GameObject();
NetworkIdentity ni = go.AddComponent<NetworkIdentity>();
ni.netId = 42;
bool result = component.SyncVarGameObjectEqual(go, identity.netId);
bool result = component.SyncVarGameObjectEqualExposed(go, identity.netId);
Assert.That(result, Is.True);

// clean up
Expand All @@ -260,7 +270,7 @@ public void SyncVarGameObjectEqualUnspawnedGO()
var go = new GameObject();
go.AddComponent<NetworkIdentity>();
LogAssert.Expect(LogType.Warning, "SetSyncVarGameObject GameObject " + go + " has a zero netId. Maybe it is not spawned yet?");
bool result = component.SyncVarGameObjectEqual(go, identity.netId);
bool result = component.SyncVarGameObjectEqualExposed(go, identity.netId);
Assert.That(result, Is.False);

// clean up
Expand All @@ -275,7 +285,7 @@ public void SyncVarGameObjectEqualUnspawnedGOZeroNetIdIsTrue()
var go = new GameObject();
go.AddComponent<NetworkIdentity>();
LogAssert.Expect(LogType.Warning, "SetSyncVarGameObject GameObject " + go + " has a zero netId. Maybe it is not spawned yet?");
bool result = component.SyncVarGameObjectEqual(go, 0);
bool result = component.SyncVarGameObjectEqualExposed(go, 0);
Assert.That(result, Is.True);

// clean up
Expand All @@ -292,7 +302,7 @@ public void SyncVarNetworkIdentityEqualZeroNetIdNullIsTrue()
// better to return false here.
// => we possibly return false so that resync doesn't happen when
// GO disappears? or not?
bool result = component.SyncVarNetworkIdentityEqual(null, 0);
bool result = component.SyncVarGameObjectEqualExposed(null, 0);
Assert.That(result, Is.True);
}

Expand All @@ -304,7 +314,7 @@ public void SyncVarNetworkIdentityEqualNull()
identity.netId = 42;

// null should return false
bool result = component.SyncVarNetworkIdentityEqual(null, identity.netId);
bool result = component.SyncVarGameObjectEqualExposed(null, identity.netId);
Assert.That(result, Is.False);
}

Expand All @@ -319,7 +329,7 @@ public void SyncVarNetworkIdentityEqualValidIdentityWithDifferentNetId()
GameObject go = new GameObject();
NetworkIdentity ni = go.AddComponent<NetworkIdentity>();
ni.netId = 43;
bool result = component.SyncVarNetworkIdentityEqual(ni, identity.netId);
bool result = component.SyncVarNetworkIdentityEqualExposed(ni, identity.netId);
Assert.That(result, Is.False);

// clean up
Expand All @@ -337,7 +347,7 @@ public void SyncVarNetworkIdentityEqualValidIdentityWithSameNetId()
var go = new GameObject();
NetworkIdentity ni = go.AddComponent<NetworkIdentity>();
ni.netId = 42;
bool result = component.SyncVarNetworkIdentityEqual(ni, identity.netId);
bool result = component.SyncVarNetworkIdentityEqualExposed(ni, identity.netId);
Assert.That(result, Is.True);

// clean up
Expand All @@ -355,7 +365,7 @@ public void SyncVarNetworkIdentityEqualUnspawnedIdentity()
var go = new GameObject();
NetworkIdentity ni = go.AddComponent<NetworkIdentity>();
LogAssert.Expect(LogType.Warning, "SetSyncVarNetworkIdentity NetworkIdentity " + ni + " has a zero netId. Maybe it is not spawned yet?");
bool result = component.SyncVarNetworkIdentityEqual(ni, identity.netId);
bool result = component.SyncVarNetworkIdentityEqualExposed(ni, identity.netId);
Assert.That(result, Is.False);

// clean up
Expand All @@ -370,7 +380,7 @@ public void SyncVarNetworkIdentityEqualUnspawnedIdentityZeroNetIdIsTrue()
var go = new GameObject();
NetworkIdentity ni = go.AddComponent<NetworkIdentity>();
LogAssert.Expect(LogType.Warning, "SetSyncVarNetworkIdentity NetworkIdentity " + ni + " has a zero netId. Maybe it is not spawned yet?");
bool result = component.SyncVarNetworkIdentityEqual(ni, 0);
bool result = component.SyncVarNetworkIdentityEqualExposed(ni, 0);
Assert.That(result, Is.True);

// clean up
Expand Down

0 comments on commit 22bf925

Please sign in to comment.