diff --git a/Source/TestFake/DependencyFakeable.swift b/Source/TestFake/DependencyFakeable.swift new file mode 100644 index 0000000..c004caa --- /dev/null +++ b/Source/TestFake/DependencyFakeable.swift @@ -0,0 +1,25 @@ +// +// DependencyFakeable.swift +// SabyTestFake +// +// Created by WOF on 11/13/23. +// + +import Foundation + +public protocol DependencyFakeable<Dependency> { + associatedtype Dependency: Fakeable + + static func fake(dependency: Dependency) -> Self +} + +extension DependencyFakeable { + static func fake(apply: (inout Dependency) -> Void) -> (Self, Dependency) { + var dependency = Dependency.fake() + apply(&dependency) + + let instance = Self.fake(dependency: dependency) + + return (instance, dependency) + } +} diff --git a/Source/TestFake/FakeDependency.swift b/Source/TestFake/FakeDependency.swift deleted file mode 100644 index 2f282ca..0000000 --- a/Source/TestFake/FakeDependency.swift +++ /dev/null @@ -1,12 +0,0 @@ -// -// FakeDependency.swift -// SabyTestFake -// -// Created by WOF on 11/13/23. -// - -import Foundation - -public protocol FakeDependency { - init() -} diff --git a/Source/TestFake/Fakeable.swift b/Source/TestFake/Fakeable.swift index 9a240a7..7079d26 100644 --- a/Source/TestFake/Fakeable.swift +++ b/Source/TestFake/Fakeable.swift @@ -7,19 +7,6 @@ import Foundation -public protocol Fakeable<Dependency> { - associatedtype Dependency: FakeDependency - - init(dependency: Dependency) -} - -extension Fakeable { - static func fake(apply: (inout Dependency) -> Void) -> (Self, Dependency) { - var dependency = Dependency() - apply(&dependency) - - let instance = Self(dependency: dependency) - - return (instance, dependency) - } +public protocol Fakeable { + static func fake() -> Self }