If I define the following protocols in the same file:
/// @mockable
protocol First {
var first: String { get }
}
/// @mockable
protocol Second {
var second: String { get }
}
/// @mockable
protocol Both: First & Second { }
Then the resulting generated mocks are:
class FirstMock: First {
init() { }
init(first: String = "") {
self.first = first
}
private(set) var firstSetCallCount = 0
var first: String = "" { didSet { firstSetCallCount += 1 } }
}
class SecondMock: Second {
init() { }
init(second: String = "") {
self.second = second
}
private(set) var secondSetCallCount = 0
var second: String = "" { didSet { secondSetCallCount += 1 } }
}
class BothMock: Both {
init() { }
init(first: String = "") {
self.first = first
}
private(set) var firstSetCallCount = 0
var first: String = "" { didSet { firstSetCallCount += 1 } }
}
Looking at the BothMock class above, it only conforms to First and doesn't include conformance to Second. This then results in a compilation error since BothMock doesn't ultimately conform to the Both protocol.
If I define the following protocols in the same file:
Then the resulting generated mocks are:
Looking at the
BothMock
class above, it only conforms toFirst
and doesn't include conformance toSecond
. This then results in a compilation error sinceBothMock
doesn't ultimately conform to theBoth
protocol.