I would like to write a class library that creates a complex object for me, but should only be shown as little as possible. I want it to be included in other projects, and there is only one call to this library, for example, it returns an object of the inner class to me. I do not want to allow others to create these objects explicitly, but still I want to create a test project for this class library.
For example:
var result = Manager.Instance.Create(definition)
This should be the only access to the class library.
Based on the definition parameter, it uses different subclasses to create the requested instance and sets its properties accordingly. Therefore, I want to somehow assure in the tests that the entire creation process worked fine. But since I also do not want to expose very small internal properties of the result object, I cannot test using this open access method, since I do not have any properties for approval.
I know that you should not test internal mechanics, and this is usually a bad design, and I also read this article , but maybe there is no library to create plus a unit test project and, possibly, subsequently restrict access to this class? with a wrapper or something?
c # unit-testing wrapper internal
Thomas Mondel Mar 15 '13 at 19:47 2013-03-15 19:47
source share