I would like to extend the existing NetworkExtension
classes by a protocol, in order to unit test my code.
I have first created the protocol for NEVPNManager
protocol NEVPNManagerProtocol {
var connection : ConnectionProtocol { get } // <-- Doesn't work
func loadFromPreferences(completionHandler: @escaping (Error?) -> Swift.Void)
func saveToPreferences(completionHandler: ((Error?) -> Swift.Void)?)
}
extension NEVPNManager: NEVPNManagerProtocol {}
And then the separate protocol for connection
property to stub it out.
protocol ConnectionProtocol {
var status: NEVPNStatus { get }
func stopVPNTunnel()
func startVPNTunnel() throws
}
extension NEVPNConnection : ConnectionProtocol {}
Inside NEVPNManager I can see that I'm confirming to the property signature, and yet Xcode doesn't believe me and claims that:
Type 'NEVPNManager' does not conform to protocol 'NEVPNManagerProtocol'
And it tries to autocorrect it like this:
extension NEVPNManager: NEVPNManagerProtocol {
var connection: ConnectionProtocol {
<#code#>
}
}
But checking the signature in NEVPNManager
, it seems correct to me:
/*!
* @property connection
* @discussion The NEVPNConnection object used for controlling the VPN tunnel.
*/
@available(iOS 8.0, *)
open var connection: NEVPNConnection { get }
Any advice?