Compare commits

...

1 Commits

Author SHA1 Message Date
Matyáš Kříž 5bb308952e Add support for `NSObjectProtocol` in ObjC mocking. 2020-07-31 19:34:54 +02:00
2 changed files with 35 additions and 0 deletions

View File

@ -68,6 +68,18 @@ public extension StubRecorder where OUT: NSObject {
}
}
public extension StubRecorder where OUT: NSObjectProtocol {
func thenReturn(_ object: OUT) {
recorder.andReturn(object)
}
}
public extension StubRecorder where OUT == Optional<NSObjectProtocol> {
func thenReturn(_ object: OUT) {
recorder.andReturn(object)
}
}
public extension StubRecorder where OUT: CuckooOptionalType, OUT.Wrapped: NSObject {
func thenReturn(_ object: OUT) {
recorder.andReturn(object)

View File

@ -0,0 +1,23 @@
//
// ObjectiveExamplesTest.swift
// Cuckoo_OCMock-iOSTests
//
// Created by Matyáš Kříž on 31/07/2020.
//
import XCTest
import Cuckoo
import CoreBluetooth
class ObjectiveExamplesTest: XCTestCase {
func testProperties() {
let mock = objcStub(for: CBCentralManager.self) { stubber, mock in
stubber.when(mock.delegate).thenReturn(nil)
}
let g = mock.delegate
objcVerify(mock.delegate)
}
}