PlayerMockMethodUtils
The native methods a mock stands in for, each named by the canonical Class.Method the production
code path bottoms out in -- the interception point is the engine API, not the Nevermore util
wrapping it. Reflection decides which paths exist; the modelled table below only says what one
answers until a test says otherwise.
Every domain is an implementation the mock runs, whether it performs the call -- Player:Kick
really removing the mock from the DataModel -- or answers it, like the truthful
MarketplaceService:UserOwnsGamePassAsync for a fake UserId. Both are displaced the same way, by
binding a stand-in over them with PlayerMockMethodUtils.bindMethod -- over the whole method, or
over one argument tuple; PlayerMockMethodUtils.writeLookup is that bind with a constant answer in
place of a callback. A domain that models argument and result shapes holds every call and every
answer to them, whichever stand-in ran.
Use PlayerMock.callMethod, PlayerMock.bindMethod, PlayerMock.readLookup, PlayerMock.writeLookup and PlayerMock.getKickMessage.
Functions
call
PlayerMockMethodUtils.call(...: any--
the engine call's own arguments; for an injected answer, what it turns on
) → ...anyCalls a native method on a mock, running whichever stand-in it has: a callback bound over the whole method through PlayerMockMethodUtils.bindMethod, otherwise one bound over these arguments -- an answer injected through PlayerMockMethodUtils.writeLookup among them -- otherwise what the domain models. The domain's own shapes hold whichever ran, the arguments going in and the answer coming back alike.
bindMethod
PlayerMockMethodUtils.bindMethod(...: any--
the arguments to bind over, or none for the whole method
) → () → ()Binds a callback to stand in for a native method on one mock, displacing whatever PlayerMockMethodUtils.call would otherwise run. The callback receives the mock followed by the call's own arguments; binding again replaces the previous callback, and binding nil removes it, leaving the domain to answer what it models again.
Passing the call's arguments narrows the binding to that one argument tuple, leaving every other tuple to what the domain models; passing none binds the whole method, which wins over any tuple binding. The domain holds the tuple named here to its argument shape, and the callback's answer to its result shape when the call runs.
The path only has to name a real method, so this reaches methods the mock models no default for.
Returns a function that removes this binding, for a maid to hold. It removes only the binding it came from: after a rebind it is a no-op, so an unwinding maid cannot tear down a stand-in that replaced its own.
unbindMethod
PlayerMockMethodUtils.unbindMethod(...: any--
the arguments the binding was made over, or none for the whole method
) → ()Removes a callback bound through PlayerMockMethodUtils.bindMethod, so the domain falls back to its modelled stand-in. The arguments are the ones the binding was made over; unbinding a method that was never bound is a no-op.
isMethodBound
PlayerMockMethodUtils.isMethodBound(...: any--
the arguments the binding was made over, or none for the whole method
) → booleanReturns whether a callback is currently bound for the method on this mock, over the arguments given or over the whole method when none are.
readLookup
PlayerMockMethodUtils.readLookup(methodPath: InstancePathTableLike,--
a known lookup domain, e.g. "GroupService.GetRolesInGroupAsync"
...: any--
the engine call's own arguments, the ones the answer turns on
) → anyReads back what the mock answers for an engine call, the test-side name for PlayerMockMethodUtils.call.
writeLookup
PlayerMockMethodUtils.writeLookup(methodPath: InstancePathTableLike,--
a known lookup domain, e.g. "MarketplaceService.UserOwnsGamePassAsync"
value: any,--
must match the domain's result shape; nil removes the injection
...: any--
the engine call's own arguments, the ones the answer turns on
) → ()Injects the answer a mock gives for one argument tuple of an engine call: the PlayerMockMethodUtils.bindMethod bind, with a constant in place of a callback. Passing nil removes the injection, leaving the domain to answer what it models again.
The domain holds the value to its result shape when it is read, the way it holds any stand-in's answer.
getKickMessage
Returns the message a mock was kicked with, or nil when the mock was never kicked. The engine has
no counterpart -- a real Player:Kick leaves nothing to read -- so this is the test-side reader
for the "Player.Kick" domain.