Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mickeyl/mockstreams
Mocking Streams in Swift
https://github.com/mickeyl/mockstreams
Last synced: 19 days ago
JSON representation
Mocking Streams in Swift
- Host: GitHub
- URL: https://github.com/mickeyl/mockstreams
- Owner: mickeyl
- License: mit
- Created: 2023-03-29T13:45:44.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-03-29T13:49:30.000Z (over 1 year ago)
- Last Synced: 2023-08-03T21:49:14.328Z (over 1 year ago)
- Language: Swift
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MockStreams
## Mocking streams in Swift.
This library contains implementations of a pair of `Stream` subclasses intended for helping with unit testing
code that uses `Foundation`'s `Stream` instances.## How to use.
First, create an instance of the `MockInputStream`:
```swift
let inputStream = MockInputStream()
```Then, create an instance of the `MockOutputStream` with the corresponding `MockInputStream` and
a dictionary of request/response pairs:```swift
let dict: [String: String] = [
"FOO": "BAR"
]let outputStream = MockOutputStream(inputStream: inputStream, stringDict: dict)
```Now, whenever you output something via the output stream, it gets forwarded as
an input to the corresponding input stream.