Skip to content
Snippets Groups Projects
Commit 3f4d0415 authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Add ConnectionIsAuthenticated functor

parent 4e5e219f
No related branches found
No related tags found
2 merge requests!102Release 1.0.0,!18Update Bindings
import Bindings
public struct Connection {
public var isAuthenticated: ConnectionIsAuthenticated
public var getId: ConnectionGetId
public var getPartner: ConnectionGetPartner
public var close: ConnectionClose
......@@ -9,6 +10,7 @@ public struct Connection {
extension Connection {
public static func live(_ bindingsConnection: BindingsConnection) -> Connection {
Connection(
isAuthenticated: .live(bindingsConnection),
getId: .live(bindingsConnection),
getPartner: .live(bindingsConnection),
close: .live(bindingsConnection)
......@@ -17,6 +19,7 @@ extension Connection {
public static func live(_ bindingsConnection: BindingsAuthenticatedConnection) -> Connection {
Connection(
isAuthenticated: .live(bindingsConnection),
getId: .live(bindingsConnection),
getPartner: .live(bindingsConnection),
close: .live(bindingsConnection)
......@@ -26,6 +29,7 @@ extension Connection {
extension Connection {
public static let unimplemented = Connection(
isAuthenticated: .unimplemented,
getId: .unimplemented,
getPartner: .unimplemented,
close: .unimplemented
......
import Bindings
import XCTestDynamicOverlay
public struct ConnectionIsAuthenticated {
public var run: () -> Bool
public func callAsFunction() -> Bool {
run()
}
}
extension ConnectionIsAuthenticated {
public static func live(_ bindingsConnection: BindingsConnection) -> ConnectionIsAuthenticated {
ConnectionIsAuthenticated { false }
}
public static func live(_ bindingsConnection: BindingsAuthenticatedConnection) -> ConnectionIsAuthenticated {
ConnectionIsAuthenticated(run: bindingsConnection.isAuthenticated)
}
}
extension ConnectionIsAuthenticated {
public static let unimplemented = ConnectionIsAuthenticated(
run: XCTUnimplemented("\(Self.self)")
)
}
import Bindings
public struct ConnectionAuthStatusProvider {
public var isAuthenticated: () -> Bool
public func callAsFunction() -> Bool {
isAuthenticated()
}
}
extension ConnectionAuthStatusProvider {
public static func live(
bindingsConnection: BindingsConnection
) -> ConnectionAuthStatusProvider {
ConnectionAuthStatusProvider { false }
}
public static func live(
bindingsAuthenticatedConnection: BindingsAuthenticatedConnection
) -> ConnectionAuthStatusProvider {
ConnectionAuthStatusProvider(
isAuthenticated: bindingsAuthenticatedConnection.isAuthenticated
)
}
}
#if DEBUG
extension ConnectionAuthStatusProvider {
public static let failing = ConnectionAuthStatusProvider {
fatalError("Not implemented")
}
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment