NetworkBehaviourTests: OnStartClient

This commit is contained in:
vis2k 2020-03-07 20:50:01 +01:00
parent ad0788fb95
commit d48ab55ede

View File

@ -179,6 +179,16 @@ public override void OnNetworkDestroy()
}
}
// we need to inherit from networkbehaviour to test protected functions
public class OnStartClientComponent : NetworkBehaviour
{
public int called;
public override void OnStartClient()
{
++called;
}
}
public class NetworkBehaviourTests
{
GameObject gameObject;
@ -1548,6 +1558,20 @@ public void OnNetworkDestroy()
// should have been forwarded to behaviours
Assert.That(comp.called, Is.EqualTo(1));
}
[Test]
public void OnStartClient()
{
// add test component
OnStartClientComponent comp = gameObject.AddComponent<OnStartClientComponent>();
Assert.That(comp.called, Is.EqualTo(0));
// call identity OnNetworkDestroy
identity.OnStartClient();
// should have been forwarded to behaviours
Assert.That(comp.called, Is.EqualTo(1));
}
}
// we need to inherit from networkbehaviour to test protected functions