An ArgumentExpectation[M, I, A] represents an expectation on input I arguments
for capability of module M that returns an effect that may produce a single A.
An Expectation[-M, +E, +A] is an immutable data structure that represents
expectations on module M capabilities.
An Invocation[M, I, A] models a single invocation of a Method[M, I, A],
including both the input to the method invocation I and the output from
the method invocation A.
A Model[M, I, A] represents a capability of module M that takes an
input I and returns an effect that may produce a single A.
A MockException is used internally by the mock framework to
signal failed expectations to the test framework.
The Mockable[A] represents a mock service builder used by the mock
framework to construct a mock implementation from a mock.
A ReturnExpectation[-I, E, +A] represents an expectation on output for capability of module M
that given input arguments I returns an effect that may fail with an error E or produce a single A.
Spyable[A] models the capability to spy on a service of type A.
Spyable[A] models the capability to spy on a service of type A.
Implementations must define both a method environment to genereate a live
environment given a mock and a method mock to generate a mock given a live
environment. Given these definitions, it is possible to convert a service to
a mock, see and modify state based on method calls, inputs, and outputs, and
then convert the mock back to a live environment to spy on the service.
An
Expectation[-M, +E, +A]is an immutable data structure that represents expectations on moduleMcapabilities.This structure is a monad, because we need the sequential composability and in Scala we get the convenient for-comprehension syntax for free.
Emptymodels expectation for no calls, the monadicunitvalueCallmodels a call onMmodules capability that takes argumentsIand returns an effect that may fail with an errorEor produce a singleAFlatMapmodels sequential composition of expectationsThe whole structure is not supposed to be consumed directly by the end user, instead it should be converted into a mocked environment (wrapped in layer) either explicitly via
toLayermethod or via implicit conversion.