when method

NanoMockCallCount when(
  1. T result,
  2. List arguments
)

Adds a mock to the NanoMock instance, which makes it so if the instance is called with arguments, the instance will return result.

The returned NanoMockCallCount can be used to access how many times the mock has been called.

Implementation

NanoMockCallCount when(T result, List<dynamic> arguments) {
  // Create an instance of _Mock with the given arguments and result.
  final mock = _Mock(result, arguments);

  // Add the mock to the list of mocks.
  _mocks.add(mock);

  // Return the mock, which is an instance of NanoMockCallCount.
  return mock;
}