add base OnSetHostVisibility test (#1749)

* add base OnSetHostVisibility test

* fix code smells
This commit is contained in:
uwee 2020-04-21 03:58:14 -04:00 committed by GitHub
parent 2d006fe730
commit 3cf686f3b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -136,6 +136,18 @@ public override void OnSetHostVisibility(bool visible)
} }
class SetHostVisibilityNetworkBehaviour : NetworkVisibility
{
public int called;
public override void OnRebuildObservers(HashSet<NetworkConnection> observers, bool initialize) { }
public override bool OnCheckObserver(NetworkConnection conn) { return true; }
public override void OnSetHostVisibility(bool visible)
{
++called;
base.OnSetHostVisibility(visible);
}
}
class CheckObserverExceptionNetworkBehaviour : NetworkVisibility class CheckObserverExceptionNetworkBehaviour : NetworkVisibility
{ {
public int called; public int called;
@ -1780,5 +1792,17 @@ public void GetDirtyComponentsMaskShouldReturnZeroWhenNoDirtyComponents()
Assert.That(mask, Is.EqualTo(0UL)); Assert.That(mask, Is.EqualTo(0UL));
} }
[Test]
public void OnSetHostVisibilityBaseTest()
{
SpriteRenderer renderer;
renderer = gameObject.AddComponent<SpriteRenderer>();
SetHostVisibilityNetworkBehaviour comp = gameObject.AddComponent<SetHostVisibilityNetworkBehaviour>();
comp.OnSetHostVisibility(false);
Assert.That(comp.called, Is.EqualTo(1));
Assert.That(renderer.enabled, Is.False);
}
} }
} }