Unit Test Byte Stream

I use the Reporting Services web service to create a report and allow the user to download it. This happens through PDF, Excel, XML, etc. And it works great. I am trying to create some separation between my reporting class and implementation, but I am struggling with how I can, I can do this in the estate that is still being tested.

Since my custom report object / class calls the web service directly, should I separate this from further use with the interfaces? Any recommendations on this subject and how it will still be tested in a block regardless of the byte source will be greatly appreciated.

+3
source share
3 answers

If you're new to Dependency Injection / Inversion of Control, this link is a great screencast by Karl Franklin and James Kovacs.

DNR TV Show # 126: James Kovacs, his own IoC container

, , , . , , , , .

+1

As already mentioned, dependency expansion / control inversion is the way to go. Code for the interface, not for a specific class. Then, when your unit test starts, it can replace the web service implementation with a mock implementation that returns fake fixed data.

+1
source

Source: https://habr.com/ru/post/1702339/


All Articles