StubbingPolicy

public enum StubbingPolicy

Given Policy for treating sequence of events (products). Used to determine if stub return values should be consumed once (.drop), or reused (.wrap). Applies to sequence as well - .drop means remove from stack after using, while .wrap iterates over sequence indefinitely.

  • default: Use current policy specified for Mock method type
  • wrap: Default policy in general. When reaching end of sequence of events, index will rewind to beginning (looping)
  • drop: With this policy, every call drops event. When events count reaches zero, given is removed from mock.
  • Use current policy specified for Mock method type

    Declaration

    Swift

    case `default`
  • Default policy in general. When reaching end of sequence of events, index will rewind to beginning (looping)

    Declaration

    Swift

    case wrap
  • With this policy, every call drops event. When events count reaches zero, given is removed from mock.

    Declaration

    Swift

    case drop
  • [Internal] Resolves used policy. If self is default, will use inherited, otherwise self

    Declaration

    Swift

    public func real(_ inherited: StubbingPolicy) -> StubbingPolicy

    Parameters

    inherited

    Inherited (usually global default) policy

    Return Value

    Policy used. Always .wrap or .drop

  • [Internal] Computes new index for stubs array. For wrap will rewind if out of bounds, for drop will not. Default is handled as wrap.

    Declaration

    Swift

    public func updated(_ index: Int, with count: Int) -> Int

    Parameters

    index

    Index of current element

    count

    Number of elements

    Return Value

    New index