Q:

Objective-C: NSInputStream and NSOutputStream for testing purposes

I have an class in my application that is initialized with an NSInputStream. For testing purposes i want to write data on an NSOutputStream which then is received by that input stream.
This should trigger the NSStreamEventHasBytesAvailable event.
The only thing is that i do not know how to set this up. Does anybody has an idea? Or suggestions how to unit test a class with has an NSStream as dependency.
Thanks

A:

This is actually really tricky since it appears that you can only create an input stream using a file, a URL or an NSData.  You can't connect an input stream to an output stream, although you might be able to write a single class that implements both interfaces.
The easiest way to do the unit test would probably be to create your input stream from an NSData whose bytes you have already read in from the output stream.

