Skip to content

Commit

Permalink
feat: rename MockService to MockableService
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelfoppolo authored and Kolos65 committed Apr 29, 2024
1 parent 01632d5 commit f931faa
Show file tree
Hide file tree
Showing 25 changed files with 44 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Sources/Mockable/Builder/EffectBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public protocol EffectBuilder<Service> {

/// The mock service associated with the Builder.
associatedtype Service: MockService
associatedtype Service: MockableService

/// Initializes a new instance of the builder with the provided `Mocker`.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
///
/// This builder is used within the context of a higher-level builder (e.g., an `ActionBuilder`)
/// to specify a desired action to perform when a particular function of a mock service is called.
public struct FunctionActionBuilder<T: MockService, ParentBuilder: EffectBuilder<T>> {
public struct FunctionActionBuilder<T: MockableService, ParentBuilder: EffectBuilder<T>> {

/// Convenient type for the associated service's Member.
public typealias Member = T.Member
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
///
/// This builder is typically used within the context of a higher-level builder (e.g., a `ReturnBuilder`)
/// to specify the desired return value or a return value producer for a particular function of a mock service.
public struct FunctionReturnBuilder<T: MockService, ParentBuilder: EffectBuilder<T>, ReturnType, ProduceType> {
public struct FunctionReturnBuilder<T: MockableService, ParentBuilder: EffectBuilder<T>, ReturnType, ProduceType> {

/// Convenient type for the associated service's Member.
public typealias Member = T.Member
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
///
/// This builder is typically used within the context of a higher-level builder (e.g., a `VerifyBuilder`)
/// to verify the expected number of invocations for a particular function of a mock service.
public struct FunctionVerifyBuilder<T: MockService, ParentBuilder: AssertionBuilder<T>> {
public struct FunctionVerifyBuilder<T: MockableService, ParentBuilder: AssertionBuilder<T>> {

/// Convenient type for the associated service's Member.
public typealias Member = T.Member
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
///
/// This builder is used within the context of a higher-level builder (e.g., an `ActionBuilder`)
/// to specify a desired action to perform when a particular throwing function of a mock service is called.
public typealias ThrowingFunctionActionBuilder<T: MockService, ParentBuilder: EffectBuilder<T>>
public typealias ThrowingFunctionActionBuilder<T: MockableService, ParentBuilder: EffectBuilder<T>>
= FunctionActionBuilder<T, ParentBuilder>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
///
/// This builder is typically used within the context of a higher-level builder (e.g., a `ReturnBuilder`)
/// to specify the desired return value or a return value producer for a throwing function of a mock service.
public struct ThrowingFunctionReturnBuilder<T: MockService, ParentBuilder: EffectBuilder<T>, ReturnType, ProduceType> {
public struct ThrowingFunctionReturnBuilder<
T: MockableService,
ParentBuilder: EffectBuilder<T>,
ReturnType,
ProduceType
> {

/// Convenient type for the associated service's Member.
public typealias Member = T.Member
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
///
/// This builder is typically used within the context of a higher-level builder (e.g., a `VerifyBuilder`)
/// to verify the expected number of invocations for a throwing function of a mock service.
public typealias ThrowingFunctionVerifyBuilder<T: MockService, ParentBuilder: AssertionBuilder<T>>
public typealias ThrowingFunctionVerifyBuilder<T: MockableService, ParentBuilder: AssertionBuilder<T>>
= FunctionVerifyBuilder<T, ParentBuilder>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// MockService.swift
// MockableService.swift
// Mockable
//
// Created by Kolos Foltanyi on 2023. 11. 13..
Expand All @@ -9,7 +9,7 @@
///
/// Conforming types must provide a `Member` type representing their members
/// as well as builders for specifying return values, actions, and verifications.
public protocol MockService {
public protocol MockableService {

/// A type representing the members of the mocked protocol.
associatedtype Member: Matchable, CaseIdentifiable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
///
/// This builder is typically used within the context of a higher-level builder (e.g., an `ActionBuilder`)
/// to specify the behavior of the getter and setter of a particular property of a mock.
public struct PropertyActionBuilder<T: MockService, ParentBuilder: EffectBuilder<T>> {
public struct PropertyActionBuilder<T: MockableService, ParentBuilder: EffectBuilder<T>> {

/// Convenient type for the associated service's Member.
public typealias Member = T.Member
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/// This builder is typically used within the context of a higher-level builder (e.g., a `ReturnBuilder`)
/// to specify the desired return value or a return value producer for the getter
/// of a particular property of a mock.
public struct PropertyReturnBuilder<T: MockService, ParentBuilder: EffectBuilder<T>, ReturnType> {
public struct PropertyReturnBuilder<T: MockableService, ParentBuilder: EffectBuilder<T>, ReturnType> {

/// Convenient type for the associated service's Member.
public typealias Member = T.Member
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
///
/// This builder is typically used within the context of a higher-level builder (e.g., a `VerifyBuilder`)
/// to verify the expected number of invocations for the getter and setter of a particular property of a mock.
public struct PropertyVerifyBuilder<T: MockService, ParentBuilder: AssertionBuilder<T>> {
public struct PropertyVerifyBuilder<T: MockableService, ParentBuilder: AssertionBuilder<T>> {

/// Convenient type for the associated service's Member.
public typealias Member = T.Member
Expand Down
2 changes: 1 addition & 1 deletion Sources/Mockable/Builder/VerifyBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public protocol AssertionBuilder<Service> {

/// The mock service associated with the Builder.
associatedtype Service: MockService
associatedtype Service: MockableService

/// Initializes a new instance of the builder with the provided `Mocker`.
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/Mockable/Mocker/Mocker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Combine
///
/// The `Mocker` class keeps track of invocations, expected return values, and actions associated with
/// specific members of a mockable service.
public class Mocker<Service: MockService> {
public class Mocker<Service: MockableService> {

// MARK: Public Properties

Expand Down
4 changes: 2 additions & 2 deletions Sources/Mockable/Utils/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
///
/// - Parameter service: The mockable service for which return values are specified.
/// - Returns: The service's return value builder.
public func given<T: MockService>(_ service: T) -> T.ReturnBuilder { service.given() }
public func given<T: MockableService>(_ service: T) -> T.ReturnBuilder { service.given() }

/// Creates a proxy for building actions for members of the given service.
///
Expand All @@ -51,4 +51,4 @@ public func given<T: MockService>(_ service: T) -> T.ReturnBuilder { service.giv
///
/// - Parameter service: The mockable service for which actions are specified.
/// - Returns: The service's action builder.
public func when<T: MockService>(_ service: T) -> T.ActionBuilder { service.when() }
public func when<T: MockableService>(_ service: T) -> T.ActionBuilder { service.when() }
2 changes: 1 addition & 1 deletion Sources/MockableMacro/Factory/MockFacotry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ extension MockFacotry {
name: requirements.syntax.name.trimmed
))
InheritedTypeSyntax(type: IdentifierTypeSyntax(
name: NS.MockService
name: NS.MockableService
))
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/MockableMacro/Utils/Namespace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ enum NS {
static let assertion: TokenSyntax = "assertion"

static let Mock: TokenSyntax = "Mock"
static let MockService: TokenSyntax = "MockService"
static let MockableService: TokenSyntax = "MockableService"
static let Bool: TokenSyntax = "Bool"
static let GenericValue: String = "GenericValue"
static let MockableAssertion: TokenSyntax = "MockableAssertion"
Expand Down
2 changes: 1 addition & 1 deletion Sources/MockableTest/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ import XCTest
/// ```
/// - Parameter service: The mockable service for which invocations are verified.
/// - Returns: The service's verification builder.
public func verify<T: MockService>(_ service: T) -> T.VerifyBuilder {
public func verify<T: MockableService>(_ service: T) -> T.VerifyBuilder {
service.verify(with: XCTAssert)
}
6 changes: 3 additions & 3 deletions Tests/MockableMacroTests/AssociatedTypeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class AssociatedTypeTests: MockableMacroTestCase {
}
#if MOCKING
final class MockTest<Item>: Test, MockService {
final class MockTest<Item>: Test, MockableService {
private var mocker = Mocker<MockTest>()
@available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ")
func given() -> ReturnBuilder {
Expand Down Expand Up @@ -116,7 +116,7 @@ final class AssociatedTypeTests: MockableMacroTestCase {
}
#if MOCKING
final class MockTest<Item>: Test, MockService where Item: Equatable, Item: Hashable {
final class MockTest<Item>: Test, MockableService where Item: Equatable, Item: Hashable {
private var mocker = Mocker<MockTest>()
@available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ")
func given() -> ReturnBuilder {
Expand Down Expand Up @@ -206,7 +206,7 @@ final class AssociatedTypeTests: MockableMacroTestCase {
}
#if MOCKING
final class MockTest<Item>: Test, MockService where Item: Equatable, Item: Hashable {
final class MockTest<Item>: Test, MockableService where Item: Equatable, Item: Hashable {
private var mocker = Mocker<MockTest>()
@available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ")
func given() -> ReturnBuilder {
Expand Down
2 changes: 1 addition & 1 deletion Tests/MockableMacroTests/AttributesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ final class AttributesTests: MockableMacroTestCase {
}
#if MOCKING
final class MockAttributeTest: AttributeTest, MockService {
final class MockAttributeTest: AttributeTest, MockableService {
private var mocker = Mocker<MockAttributeTest>()
@available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ")
func given() -> ReturnBuilder {
Expand Down
6 changes: 3 additions & 3 deletions Tests/MockableMacroTests/ExoticParameterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class ExoticParameterTests: MockableMacroTestCase {
}
#if MOCKING
final class MockTest: Test, MockService {
final class MockTest: Test, MockableService {
private var mocker = Mocker<MockTest>()
@available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ")
func given() -> ReturnBuilder {
Expand Down Expand Up @@ -112,7 +112,7 @@ final class ExoticParameterTests: MockableMacroTestCase {
}
#if MOCKING
final class MockTest: Test, MockService {
final class MockTest: Test, MockableService {
private var mocker = Mocker<MockTest>()
@available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ")
func given() -> ReturnBuilder {
Expand Down Expand Up @@ -200,7 +200,7 @@ final class ExoticParameterTests: MockableMacroTestCase {
}
#if MOCKING
final class MockTest: Test, MockService {
final class MockTest: Test, MockableService {
private var mocker = Mocker<MockTest>()
@available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ")
func given() -> ReturnBuilder {
Expand Down
6 changes: 3 additions & 3 deletions Tests/MockableMacroTests/FunctionEffectTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class FunctionEffectTests: MockableMacroTestCase {
}
#if MOCKING
final class MockTest: Test, MockService {
final class MockTest: Test, MockableService {
private var mocker = Mocker<MockTest>()
@available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ")
func given() -> ReturnBuilder {
Expand Down Expand Up @@ -136,7 +136,7 @@ final class FunctionEffectTests: MockableMacroTestCase {
}
#if MOCKING
final class MockTest: Test, MockService {
final class MockTest: Test, MockableService {
private var mocker = Mocker<MockTest>()
@available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ")
func given() -> ReturnBuilder {
Expand Down Expand Up @@ -228,7 +228,7 @@ final class FunctionEffectTests: MockableMacroTestCase {
}
#if MOCKING
final class MockTest: Test, MockService {
final class MockTest: Test, MockableService {
private var mocker = Mocker<MockTest>()
@available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ")
func given() -> ReturnBuilder {
Expand Down
6 changes: 3 additions & 3 deletions Tests/MockableMacroTests/GenericFunctionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class GenericFunctionTests: MockableMacroTestCase {
}
#if MOCKING
final class MockTest: Test, MockService {
final class MockTest: Test, MockableService {
private var mocker = Mocker<MockTest>()
@available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ")
func given() -> ReturnBuilder {
Expand Down Expand Up @@ -112,7 +112,7 @@ final class GenericFunctionTests: MockableMacroTestCase {
}
#if MOCKING
final class MockTest: Test, MockService {
final class MockTest: Test, MockableService {
private var mocker = Mocker<MockTest>()
@available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ")
func given() -> ReturnBuilder {
Expand Down Expand Up @@ -204,7 +204,7 @@ final class GenericFunctionTests: MockableMacroTestCase {
}
#if MOCKING
final class MockTest: Test, MockService {
final class MockTest: Test, MockableService {
private var mocker = Mocker<MockTest>()
@available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ")
func given() -> ReturnBuilder {
Expand Down
4 changes: 2 additions & 2 deletions Tests/MockableMacroTests/InitRequirementTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class InitRequirementTests: MockableMacroTestCase {
}
#if MOCKING
final class MockTest: Test, MockService {
final class MockTest: Test, MockableService {
private var mocker = Mocker<MockTest>()
@available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ")
func given() -> ReturnBuilder {
Expand Down Expand Up @@ -103,7 +103,7 @@ final class InitRequirementTests: MockableMacroTestCase {
}
#if MOCKING
final class MockTest: Test, MockService {
final class MockTest: Test, MockableService {
private var mocker = Mocker<MockTest>()
@available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ")
func given() -> ReturnBuilder {
Expand Down
4 changes: 2 additions & 2 deletions Tests/MockableMacroTests/NameCollisionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class NameCollisionTests: MockableMacroTestCase {
}
#if MOCKING
final class MockTest: Test, MockService {
final class MockTest: Test, MockableService {
private var mocker = Mocker<MockTest>()
@available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ")
func given() -> ReturnBuilder {
Expand Down Expand Up @@ -137,7 +137,7 @@ final class NameCollisionTests: MockableMacroTestCase {
}
#if MOCKING
final class MockTest: Test, MockService {
final class MockTest: Test, MockableService {
private var mocker = Mocker<MockTest>()
@available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ")
func given() -> ReturnBuilder {
Expand Down
6 changes: 3 additions & 3 deletions Tests/MockableMacroTests/PropertyRequirementTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class PropertyRequirementTests: MockableMacroTestCase {
}
#if MOCKING
final class MockTest: Test, MockService {
final class MockTest: Test, MockableService {
private var mocker = Mocker<MockTest>()
@available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ")
func given() -> ReturnBuilder {
Expand Down Expand Up @@ -141,7 +141,7 @@ final class PropertyRequirementTests: MockableMacroTestCase {
}
#if MOCKING
final class MockTest: Test, MockService {
final class MockTest: Test, MockableService {
private var mocker = Mocker<MockTest>()
@available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ")
func given() -> ReturnBuilder {
Expand Down Expand Up @@ -274,7 +274,7 @@ final class PropertyRequirementTests: MockableMacroTestCase {
}
#if MOCKING
final class MockTest: Test, MockService {
final class MockTest: Test, MockableService {
private var mocker = Mocker<MockTest>()
@available(*, deprecated, message: "Use given(_ service:) of Mockable instead. ")
func given() -> ReturnBuilder {
Expand Down

0 comments on commit f931faa

Please sign in to comment.