### Install Simple Mock Swift using Swift Package Manager Source: https://github.com/tavernari/simplemock/blob/main/README.md This snippet demonstrates how to integrate Simple Mock Swift into your project using Swift Package Manager. It involves adding the library as a dependency in your `Package.swift` file and linking it to your target. ```Swift dependencies: [ .package(url: "https://github.com/Tavernari/SimpleMock", from: "0.1.0") ], targets: [ .target( name: "YourTargetName", dependencies: ["SimpleMock"] ) ] ``` -------------------------------- ### Implement Basic Mocking with Swift `Mock` Protocol Source: https://github.com/tavernari/simplemock/blob/main/README.md This example illustrates how to create a basic mock object by conforming to the `Mock` protocol. It shows defining an enum to represent mockable methods and using the `resolve` method to handle expected behaviors for synchronous operations. ```Swift class ServiceMock: Service, Mock { enum Methods: Hashable { case save(_ id: String, _ value: Int) case load(_ id: String) } func save(_ id: String, _ value: Int) throws { return try self.resolve(method: .save(id, value)) } func load(_ id: String) throws -> Int { return try self.resolve(method: .load(id)) } } ``` -------------------------------- ### Implement Concurrency-Safe Mocking with Swift `ActorMock` Protocol Source: https://github.com/tavernari/simplemock/blob/main/README.md This snippet demonstrates how to implement a concurrency-safe mock using the `ActorMock` protocol. It's designed for asynchronous operations, ensuring thread-safe handling of mock expectations in concurrent environments. ```Swift class ActorServiceMock: Service, ActorMock { enum Methods: Hashable { case save(_ id: String, _ value: Int) case load(_ id: String) } func save(_ id: String, _ value: Int) async throws { return try await self.resolve(method: .save(id, value)) } func load(_ id: String) async throws -> Int { return try await self.resolve(method: .load(id)) } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.