Test improved

This commit is contained in:
vis2k 2021-10-09 14:53:09 +08:00
parent 304f2b6f53
commit 91f2c19c2d

View File

@ -131,19 +131,17 @@ public void Hook_CalledWhenSyncingChangedValue(bool intialState)
out _, out _, out HookBehaviour serverObject, out _, out _, out HookBehaviour serverObject,
out _, out _, out HookBehaviour clientObject); out _, out _, out HookBehaviour clientObject);
const int clientValue = 10;
const int serverValue = 24; const int serverValue = 24;
// change it on server // change it on server
serverObject.value = serverValue; serverObject.value = serverValue;
clientObject.value = clientValue;
// hook should change it on client // hook should change it on client
int callCount = 0; int callCount = 0;
clientObject.HookCalled += (oldValue, newValue) => clientObject.HookCalled += (oldValue, newValue) =>
{ {
callCount++; callCount++;
Assert.That(oldValue, Is.EqualTo(clientValue)); Assert.That(oldValue, Is.EqualTo(0));
Assert.That(newValue, Is.EqualTo(serverValue)); Assert.That(newValue, Is.EqualTo(serverValue));
}; };
@ -215,19 +213,17 @@ public void StaticMethod_HookCalledWhenSyncingChangedValue(bool intialState)
out _, out _, out StaticHookBehaviour serverObject, out _, out _, out StaticHookBehaviour serverObject,
out _, out _, out StaticHookBehaviour clientObject); out _, out _, out StaticHookBehaviour clientObject);
const int clientValue = 10;
const int serverValue = 24; const int serverValue = 24;
// change it on server // change it on server
serverObject.value = serverValue; serverObject.value = serverValue;
clientObject.value = clientValue;
// hook should change it on client // hook should change it on client
int hookcallCount = 0; int hookcallCount = 0;
StaticHookBehaviour.HookCalled += (oldValue, newValue) => StaticHookBehaviour.HookCalled += (oldValue, newValue) =>
{ {
hookcallCount++; hookcallCount++;
Assert.That(oldValue, Is.EqualTo(clientValue)); Assert.That(oldValue, Is.EqualTo(0));
Assert.That(newValue, Is.EqualTo(serverValue)); Assert.That(newValue, Is.EqualTo(serverValue));
}; };