From cafcb00f3edce258e017e53b2b89ce231fc22b9b Mon Sep 17 00:00:00 2001 From: Ondrej Rafaj Date: Tue, 20 Mar 2018 11:54:10 +0000 Subject: [PATCH] removing services --- .../Services/Services+Testing.swift | 24 +++++++++++++++++++ .../Properties/TestableProperty.swift | 2 +- Sources/VaporTestTools/TestTools.swift | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 Sources/VaporTestTools/Extensions/Services/Services+Testing.swift diff --git a/Sources/VaporTestTools/Extensions/Services/Services+Testing.swift b/Sources/VaporTestTools/Extensions/Services/Services+Testing.swift new file mode 100644 index 0000000..7b8f68d --- /dev/null +++ b/Sources/VaporTestTools/Extensions/Services/Services+Testing.swift @@ -0,0 +1,24 @@ +// +// Services+Testing.swift +// VaporTestTools +// +// Created by Ondrej Rafaj on 20/03/2018. +// + +import Foundation +@testable import Service + + +extension TestableProperty where TestableType == Services { + + public mutating func remove(type: S.Type) { + if let existing = element.factories.index(where: { + $0.serviceType is S.Type + }) { + element.factories.remove(at: existing) + } + } + +} + + diff --git a/Sources/VaporTestTools/Properties/TestableProperty.swift b/Sources/VaporTestTools/Properties/TestableProperty.swift index 158c231..fb18801 100644 --- a/Sources/VaporTestTools/Properties/TestableProperty.swift +++ b/Sources/VaporTestTools/Properties/TestableProperty.swift @@ -10,7 +10,7 @@ import Foundation public struct TestableProperty { - public let element: TestableType + public var element: TestableType init(_ obj: TestableType) { element = obj diff --git a/Sources/VaporTestTools/TestTools.swift b/Sources/VaporTestTools/TestTools.swift index 0c18cab..2b994a0 100644 --- a/Sources/VaporTestTools/TestTools.swift +++ b/Sources/VaporTestTools/TestTools.swift @@ -36,6 +36,7 @@ extension Request: Testable { } extension HTTPRequest: Testable { } extension Response: Testable { } extension Application: Testable { } +extension Services: Testable { } extension Dictionary: Testable where Key == String, Value == String {