Skip to content

Commit

Permalink
test: fixing tests for PR(#1171)
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Frowen committed Feb 16, 2024
1 parent 7a8ff46 commit 8a72ac3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions Assets/Mirage/Runtime/ClientObjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,11 @@ public void UnregisterPrefab(NetworkIdentity identity)
/// <param name="unspawnHandler">A method to use as a custom un-spawnhandler on clients.</param>
public void RegisterSpawnHandler(NetworkIdentity identity, SpawnHandlerDelegate spawnHandler, UnSpawnDelegate unspawnHandler)
{
// check identity has a hash before Validate so that there is good error meessage
ThrowIfZeroHash(identity);
var prefabHash = identity.PrefabHash;
ValidateRegisterSpawnHandler(prefabHash, spawnHandler, unspawnHandler);

_handlers[prefabHash] = new SpawnHandler(identity, spawnHandler, unspawnHandler);
}

Expand All @@ -323,9 +325,11 @@ public void RegisterSpawnHandler(int prefabHash, SpawnHandlerDelegate spawnHandl

public void RegisterSpawnHandler(NetworkIdentity identity, SpawnHandlerAsyncDelegate spawnHandler, UnSpawnDelegate unspawnHandler)
{
// check identity has a hash before Validate so that there is good error meessage
ThrowIfZeroHash(identity);
var prefabHash = identity.PrefabHash;
ValidateRegisterSpawnHandler(prefabHash, spawnHandler, unspawnHandler);

_handlers[prefabHash] = new SpawnHandler(identity, spawnHandler, unspawnHandler);
}

Expand Down
4 changes: 2 additions & 2 deletions Assets/Tests/Runtime/ClientServer/ClientObjectManagerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void RegisterPrefabDelegate()

Assert.IsTrue(clientObjectManager._handlers.ContainsKey(identity.PrefabHash));
var handlers = clientObjectManager._handlers[identity.PrefabHash];
Assert.That(handlers.Prefab == null, "should not have added prefab with handlers");
Assert.That(handlers.Prefab == identity, "prefab should also be added to handler if it is passed to regiester so that user can use it if they want to");
Assert.That(handlers.Handler == TestSpawnDelegate);
Assert.That(handlers.UnspawnHandler == TestUnspawnDelegate);
}
Expand All @@ -81,7 +81,7 @@ public void IsAllowedToGiveNullUnspawn()

Assert.IsTrue(clientObjectManager._handlers.ContainsKey(identity.PrefabHash));
var handlers = clientObjectManager._handlers[identity.PrefabHash];
Assert.That(handlers.Prefab == null, "should not have added prefab with handlers");
Assert.That(handlers.Prefab == identity, "prefab should also be added to handler if it is passed to regiester so that user can use it if they want to");
Assert.That(handlers.Handler == TestSpawnDelegate);
Assert.That(handlers.UnspawnHandler == null);
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Tests/Runtime/Host/ClientObjectManagerHostTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void RegisterPrefabDelegateTest()

Assert.IsTrue(clientObjectManager._handlers.ContainsKey(identity.PrefabHash));
var handler = clientObjectManager._handlers[identity.PrefabHash];
Assert.That(handler.Prefab == null);
Assert.That(handler.Prefab == identity);
Assert.That(handler.Handler == TestSpawnDelegate);
Assert.That(handler.UnspawnHandler == TestUnspawnDelegate);
}
Expand Down

0 comments on commit 8a72ac3

Please sign in to comment.