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)
-
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.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:
- if parameter is .any - it is equal to any other parameter
- if both are .value - then compare wrapped ValueType instances.
- 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
-
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
-
Used for invocations sorting purpose.
Declaration
Swift
var intValue: Int { get }
-
[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] 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
-
[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
-
[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
-
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
-
[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
-
Undocumented
Declaration
Swift
static var notNil: Parameter<ValueType> { get }
-
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
-
Used for invocations sorting purpose.
Declaration
Swift
var intValue: Int { get }
-
Declaration
Swift
public typealias StringLiteralType = ValueType.StringLiteralType
-
Declaration
Swift
public typealias ExtendedGraphemeClusterLiteralType = ValueType.ExtendedGraphemeClusterLiteralType
-
Declaration
Swift
public typealias UnicodeScalarLiteralType = ValueType.UnicodeScalarLiteralType
-
Declaration
Swift
public init(stringLiteral value: StringLiteralType)
-
Declaration
Swift
public init(extendedGraphemeClusterLiteral value: ExtendedGraphemeClusterLiteralType)
-
Declaration
Swift
public init(unicodeScalarLiteral value: UnicodeScalarLiteralType)
-
Declaration
Swift
public init(nilLiteral: ())
-
Declaration
Swift
public typealias IntegerLiteralType = ValueType.IntegerLiteralType
-
Declaration
Swift
public init(integerLiteral value: ValueType.IntegerLiteralType)
-
Declaration
Swift
public typealias BooleanLiteralType = ValueType.BooleanLiteralType
-
Declaration
Swift
public init(booleanLiteral value: BooleanLiteralType)
-
Declaration
Swift
public typealias FloatLiteralType = ValueType.FloatLiteralType
-
Declaration
Swift
public init(floatLiteral value: FloatLiteralType)
-
Declaration
Swift
public typealias ArrayLiteralElement = ValueType.ArrayLiteralElement
-
Declaration
Swift
public init(arrayLiteral elements: ArrayLiteralElement...)
-
Declaration
Swift
public typealias Key = ValueType.Key
-
Declaration
Swift
public typealias Value = ValueType.Value