I'd like to run some NUnit unit tests against a class in a .Net class library assembly which is designed to be hosted by an external process (outside of my control) and loaded at runtime.
The class I want to test derives from a class defined within the host exe that requires it to be instantiated within the host process. Any attempt to instantiate a derivative of the base class outside of the host process fails with an exception.
I am therefore not able to test the class in the NUnit gui or console test hosts by simply loading the assembly and instantiating the class. Does anyone have any suggestions as to how I can execute these tests?
I'd probably split the class into two classes - an 'outer' class that derives from the type in the external process, and an 'inner' class that does all the work, but does not inherit from anything that you do not control.
Then, test the inner class, and leave the outer class as devoid of logic as possible.
Unit testing is almost always easier when you can isolate your code from your dependencies in some fashion.