Parameter

public enum Parameter<ValueType>
extension Parameter:
    ExpressibleByStringLiteral,
    ExpressibleByExtendedGraphemeClusterLiteral,
    ExpressibleByUnicodeScalarLiteral
    where ValueType: ExpressibleByStringLiteral
extension Parameter: ExpressibleByNilLiteral where ValueType: ExpressibleByNilLiteral
extension Parameter: ExpressibleByIntegerLiteral where ValueType: ExpressibleByIntegerLiteral
extension Parameter: ExpressibleByBooleanLiteral where ValueType: ExpressibleByBooleanLiteral
extension Parameter: ExpressibleByFloatLiteral where ValueType: ExpressibleByFloatLiteral
extension Parameter: ExpressibleByArrayLiteral where ValueType: ExpressibleByArrayLiteral
extension Parameter: ExpressibleByDictionaryLiteral where ValueType: ExpressibleByDictionaryLiteral, ValueType.Key: Hashable

Parameter wraps method attribute, allowing to make a difference between explicit value, expressed by .value case and wildcard value, expressed by .any case.

Whole idea is to be able to test and specify behaviours, in both generic and explicit way (and any mix of these two). Every test method matches mock methods in signature, but changes attributes types to Parameter.

That allows pattern like matching between two Parameter values:

  • .any is equal to every other parameter. (!!! actual case name is ._, but it is advised to use .any)
  • .value(p1) is equal to .value(p2) only, when p1 == p2

Important! Comparing parameters, where ValueType is not Equatable will result in fatalError, unless you register comparator for its ValueType in Matcher instance used (typically Matcher.default)

  • any: represents and matches any parameter value
  • value: represents explicit parameter value
  • _

    Wildcard - any value

    Declaration

    Swift

    case `_`
  • Explicit value

    Declaration

    Swift

    case value(ValueType)
  • Any value matching

    Declaration

    Swift

    case matching((ValueType) -> Bool)
  • any

    Represents and matches any parameter value - syntactic sugar for ._ case.

    Declaration

    Swift

    public static var any: Parameter<ValueType> { get }
  • Represents and matches any parameter value - syntactic sugar for ._ case. Used, when needs to explicitely specify wrapped ValueType type, to resolve ambiguity between methods with same signatures, but different attribute types.

    Declaration

    Swift

    public static func any<T>(_ type: T.Type) -> Parameter<T>

    Parameters

    type

    Explicitly specify ValueType type

    Return Value

    any parameter

  • Undocumented

    Declaration

    Swift

    public var shortDescription: String { get }
  • Returns whether given two parameters are matching each other, with following rules:

    1. if parameter is .any - it is equal to any other parameter
    2. if both are .value - then compare wrapped ValueType instances.
    3. if they are not Equatable (or not a Sequences of Equatable), use provided matcher instance

    Declaration

    Swift

    static func compare(lhs: Parameter<ValueType>, rhs: Parameter<ValueType>, with matcher: Matcher) -> Bool

    Parameters

    lhs

    First parameter

    rhs

    Second parameter

    matcher

    Matcher instance

    Return Value

    true, if first is matching second

  • [Internal] Wraps as generic Parameter instance. Should not be ever called directly.

    Declaration

    Swift

    func wrapAsGeneric() -> Parameter<GenericAttribute>

    Return Value

    Wrapped parameter

  • [Internal] Wraps as generic Parameter instance. Should not be ever called directly.

    Declaration

    Swift

    func typeErasedAttribute() -> Parameter<TypeErasedAttribute>

    Return Value

    Wrapped parameter

  • [Internal] Fatal error raised when no comparator or default comparator found for ValueType.

    Declaration

    Swift

    static func noComparatorFailure(in matcher: Matcher) -> Swift.Never

Parameter convenience initializers

  • Allows combining multiple Parameter constraints into one Parameter constraint.

    Declaration

    Swift

    static func all(_ matching: Parameter<ValueType>...) -> Parameter<ValueType>

    Parameters

    matching

    List of parameter constraints

Ordering parameters

  • Used for invocations sorting purpose.

    Declaration

    Swift

    var intValue: Int { get }

Available where ValueType: TypeErasedValue

  • [Internal] Compare two parameters

    Declaration

    Swift

    static func compare(lhs: Parameter<ValueType>, rhs: Parameter<ValueType>, with matcher: Matcher) -> Bool

    Parameters

    lhs

    one

    rhs

    other

    matcher

    Matcher instance used for comparison

    Return Value

    true if they are matching, false otherwise

Available where ValueType: Sequence, ValueType: Equatable

  • [Internal] Compare two parameters

    Declaration

    Swift

    static func compare(lhs: Parameter<ValueType>, rhs: Parameter<ValueType>, with matcher: Matcher) -> Bool

    Parameters

    lhs

    one

    rhs

    other

    matcher

    Matcher instance used for comparison

    Return Value

    true if they are matching, false otherwise

  • [Internal] Wraps as generic Parameter instance. Should not be ever called directly.

    Declaration

    Swift

    func wrapAsGeneric() -> Parameter<GenericAttribute>

    Return Value

    Wrapped parameter

  • [Internal] Wraps as generic Parameter instance. Should not be ever called directly.

    Declaration

    Swift

    func typeErasedAttribute() -> Parameter<TypeErasedAttribute>

    Return Value

    Wrapped parameter

Available where ValueType: Sequence, ValueType.Element: Equatable

  • [Internal] Compare two parameters

    Declaration

    Swift

    static func compare(lhs: Parameter<ValueType>, rhs: Parameter<ValueType>, with matcher: Matcher) -> Bool

    Parameters

    lhs

    one

    rhs

    other

    matcher

    Matcher instance used for comparison

    Return Value

    true if they are matching, false otherwise

  • [Internal] Wraps as generic Parameter instance. Should not be ever called directly.

    Declaration

    Swift

    func wrapAsGeneric() -> Parameter<GenericAttribute>

    Return Value

    Wrapped parameter

  • [Internal] Wraps as generic Parameter instance. Should not be ever called directly.

    Declaration

    Swift

    func typeErasedAttribute() -> Parameter<TypeErasedAttribute>

    Return Value

    Wrapped parameter

Available where ValueType: Sequence, ValueType.Element: Equatable, ValueType: Equatable

  • [Internal] Compare two parameters

    Declaration

    Swift

    static func compare(lhs: Parameter<ValueType>, rhs: Parameter<ValueType>, with matcher: Matcher) -> Bool

    Parameters

    lhs

    one

    rhs

    other

    matcher

    Matcher instance used for comparison

    Return Value

    true if they are matching, false otherwise

  • [Internal] Wraps as generic Parameter instance. Should not be ever called directly.

    Declaration

    Swift

    func wrapAsGeneric() -> Parameter<GenericAttribute>

    Return Value

    Wrapped parameter

  • [Internal] Wraps as generic Parameter instance. Should not be ever called directly.

    Declaration

    Swift

    func typeErasedAttribute() -> Parameter<TypeErasedAttribute>

    Return Value

    Wrapped parameter

Available where ValueType: Sequence

  • Element

    Declaration

    Swift

    typealias Element = ValueType.Element
  • [Internal] Compare two parameters

    Declaration

    Swift

    static func compare(lhs: Parameter<ValueType>, rhs: Parameter<ValueType>, with matcher: Matcher) -> Bool

    Parameters

    lhs

    one

    rhs

    other

    matcher

    Matcher instance used for comparison

    Return Value

    true if they are matching, false otherwise

  • [Internal] Wraps as generic Parameter instance. Should not be ever called directly.

    Declaration

    Swift

    func wrapAsGeneric() -> Parameter<GenericAttribute>

    Return Value

    Wrapped parameter

  • [Internal] Wraps as generic Parameter instance. Should not be ever called directly.

    Declaration

    Swift

    func typeErasedAttribute() -> Parameter<TypeErasedAttribute>

    Return Value

    Wrapped parameter

Available where ValueType: Equatable

  • [Internal] Compare two parameters

    Declaration

    Swift

    static func compare(lhs: Parameter<ValueType>, rhs: Parameter<ValueType>, with matcher: Matcher) -> Bool

    Parameters

    lhs

    one

    rhs

    other

    matcher

    Matcher instance used for comparison

    Return Value

    true if they are matching, false otherwise

  • [Internal] Wraps as generic Parameter instance. Should not be ever called directly.

    Declaration

    Swift

    func wrapAsGeneric() -> Parameter<GenericAttribute>

    Return Value

    Wrapped parameter

  • [Internal] Wraps as generic Parameter instance. Should not be ever called directly.

    Declaration

    Swift

    func typeErasedAttribute() -> Parameter<TypeErasedAttribute>

    Return Value

    Wrapped parameter

Available where ValueType: OptionalType

  • Undocumented

    Declaration

    Swift

    static var notNil: Parameter<ValueType> { get }

Available where ValueType: AnyObject

  • Represents and matches values on an “same instance” basis.

    Declaration

    Swift

    static func sameInstance<T>(as instance: T) -> Parameter<ValueType> where T : AnyObject

    Parameters

    instance

    Instance to match against

  • Represents and matches whether parameter is of specific type, using is operator.

    Declaration

    Swift

    static func isInstance<T>(of type: T.Type) -> Parameter<ValueType> where T : AnyObject

    Parameters

    type

    Type to match against

Available where ValueType: TypeErasedValue

  • Used for invocations sorting purpose.

    Declaration

    Swift

    var intValue: Int { get }

Available where ValueType: ExpressibleByStringLiteral

Available where ValueType: ExpressibleByNilLiteral

Available where ValueType: ExpressibleByIntegerLiteral

Available where ValueType: ExpressibleByBooleanLiteral

Available where ValueType: ExpressibleByFloatLiteral

Available where ValueType: ExpressibleByArrayLiteral

Available where ValueType: ExpressibleByDictionaryLiteral, ValueType.Key: Hashable

  • Key

    Declaration

    Swift

    public typealias Key = ValueType.Key
  • Declaration

    Swift

    public typealias Value = ValueType.Value
  • Declaration

    Swift

    public init(dictionaryLiteral elements: (Key, Value)...)