I am using C# with Unity3D.
There is an object type called Transform that I cannot directly instantiate.
I want to do some unit testing on a function that uses Transform.
Is this the correct way to do it?
Use the adapter pattern by:
- creating a class (TransformAdapter) that has the same functionality as Transform
- (when running for real) extending TransformAdapter, with a class called UnityTransform, that holds a Transform and just forwards on any functionality to Transform.
- (when running in unit test) extending TransformAdapter, with a class caled MockTransform, that just holds values set by my unit test.
Update:
It appears that in many situations, I don't need to create abstract classes to mock out the objects, as I can instantiate the objects from unit tests if I run the unit tests from the Unity3d Unit Testing window. I cannot instantiate the objects if running the tests from MonoDevelop.