Skip to content

Commit

Permalink
Linux support (#116)
Browse files Browse the repository at this point in the history
* Linux build

* Remove "result of call to 'registerClass' is unused" warning
  • Loading branch information
vox-humana authored May 19, 2022
1 parent b6fe7dc commit 5b270d7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Sources/Mock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

import Foundation
import XCTest
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

/// A Mock which can be used for mocking data requests with the `Mocker` by calling `Mocker.register(...)`.
public struct Mock: Equatable {
Expand Down
5 changes: 4 additions & 1 deletion Sources/Mocker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
//

import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

/// Can be used for registering Mocked data, returned by the `MockingURLProtocol`.
public struct Mocker {
Expand Down Expand Up @@ -73,7 +76,7 @@ public struct Mocker {

private init() {
// Whenever someone is requesting the Mocker, we want the URL protocol to be activated.
URLProtocol.registerClass(MockingURLProtocol.self)
_ = URLProtocol.registerClass(MockingURLProtocol.self)
}

/// Register new Mocked data. If a mock for the same URL and HTTPMethod exists, it will be overwritten.
Expand Down
3 changes: 3 additions & 0 deletions Sources/MockingURLProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
//

import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

/// The protocol which can be used to send Mocked data back. Use the `Mocker` to register `Mock` data
open class MockingURLProtocol: URLProtocol {
Expand Down

0 comments on commit 5b270d7

Please sign in to comment.