Created
December 8, 2021 20:09
-
-
Save Nikoloutsos/1dfa20129f1f95155fd107362a331e16 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FooProtocolMock: FooProtocol { | |
//MARK: - foo1 | |
var foo1CallsCount = 0 | |
var foo1Called: Bool { | |
return foo1CallsCount > 0 | |
} | |
var foo1Closure: (() -> Void)? | |
func foo1() { | |
foo1CallsCount += 1 | |
foo1Closure?() | |
} | |
//MARK: - foo2 | |
var foo2CallsCount = 0 | |
var foo2Called: Bool { | |
return foo2CallsCount > 0 | |
} | |
var foo2ReturnValue: String! | |
var foo2Closure: (() -> String)? | |
func foo2() -> String { | |
foo2CallsCount += 1 | |
return foo2Closure.map({ $0() }) ?? foo2ReturnValue | |
} | |
//MARK: - foo3 | |
var foo3StrIntCallsCount = 0 | |
var foo3StrIntCalled: Bool { | |
return foo3StrIntCallsCount > 0 | |
} | |
var foo3StrIntReceivedArguments: (str: String, int: Int)? | |
var foo3StrIntReceivedInvocations: [(str: String, int: Int)] = [] | |
var foo3StrIntReturnValue: Int! | |
var foo3StrIntClosure: ((String, Int) -> Int)? | |
func foo3(str: String, int: Int) -> Int { | |
foo3StrIntCallsCount += 1 | |
foo3StrIntReceivedArguments = (str: str, int: int) | |
foo3StrIntReceivedInvocations.append((str: str, int: int)) | |
return foo3StrIntClosure.map({ $0(str, int) }) ?? foo3StrIntReturnValue | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment