Add support for `NSObjectProtocol` in ObjC mocking.
This commit is contained in:
parent
1d31d53b04
commit
5bb308952e
|
@ -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 {
|
public extension StubRecorder where OUT: CuckooOptionalType, OUT.Wrapped: NSObject {
|
||||||
func thenReturn(_ object: OUT) {
|
func thenReturn(_ object: OUT) {
|
||||||
recorder.andReturn(object)
|
recorder.andReturn(object)
|
||||||
|
|
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue