4 ms·
In C#, it's just about the only way to unit test aside from making abstract/virtual or using something like TypeMock (paid). The author suggests using virtual,
by johnnyb9 9y ago
In C#, it's just about the only way to unit test aside from making abstract/virtual or using something like TypeMock (paid).
The author suggests using virtual, but if your intent is not to allow child classes to override the implementation, this is certainly not "pure".
Visual Studio & ReSharper makes the code generation (Refactor > Extract Interface) and maintenance upkeep trivial anyway.
- flukus 9y agoYou don't need to mock a POCO at all, it's just a collection of values with no functionality. I'm not part of the anti-mocking brigade, but for POCO's you should always just use the real thing.
- bonesss 9y agoPOCOs and functionality are orthogonal to one another. Plain Old Class Object means no special inheritance chains or attributes, just a "plain old" class. By way of example: this contrasts with old Entity Framework or other ORMs that made you inherit from a certain kind of class, breaking the objects original intent, and hurting you when it came time to port to another framework, or serialize, or maintain your own class hierarchy. Even what DDDers would call a Value Object could and should still have relevant business logic attached to them. For test-ability and portability you don't want your classes married to any particular framework, but your objects are still responsible for hiding relevant information.
- JackMorgan 9y agoUnless you use a pattern like SimpleMock! http://deliberate-software.com/simplemock-unit-test-mocking/ http://deliberate-software.com/simplemock-unit-test-mocking/