I need to write unit tests for methods that compress and decompress an ArraySegment
object. There are plenty of strange treatments inside these methods which I do not need to understand. (They also use some system methods — I don't know their implementation.)
The problem lies in how to actually test such things. I could check what the result is for the compression method for concrete input — Lorem ipsum dolor sit amet, consectetur adipisicing elit.
— and create a test case based on this experiment, but this solution doesn't test any border cases.
I could also test whether doing compression and then decompression on some sequence gives me the first input sequence, but that would not be a pure unit test.
Have you ever come across such a problem? Is there any good solution for it?
I find myself writing tests like this periodically. Writing tests for code that wraps encryption works similarly.
You can't mock or stub code that you don't fully understand (i.e. code whose results you can't predict exactly), so don't worry aboout writing pure unit tests.