Skip to content

Commit

Permalink
refactor: split DependencyFakeable from Fakeable
Browse files Browse the repository at this point in the history
  • Loading branch information
0xWOF committed Nov 13, 2023
1 parent a99ccf7 commit 6502b47
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
25 changes: 25 additions & 0 deletions Source/TestFake/DependencyFakeable.swift
Original file line number Diff line number Diff line change
@@ -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)
}
}
12 changes: 0 additions & 12 deletions Source/TestFake/FakeDependency.swift

This file was deleted.

17 changes: 2 additions & 15 deletions Source/TestFake/Fakeable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 6502b47

Please sign in to comment.