How to extend an object that has a private constructor?

I have a person object that has a private constructor which is coming from an external service. In the constructor the firstname and lastname are taken off of the database. now for unit testing, I want to feed the firstname and lastname in order to not hit the database in unit test.

How can I extend my class and add a constructor extension that feeds the firstname and lastname in the unit test?

Jon Skeet
people
quotationmark

If a class only has a private constructor, you simply can't derive from it except as a nested type. Basically it sounds like the type you want to use is not amenable to being used in tests :(

When you say the type "is coming from an external service" - what do you mean, exactly? Do you mean the source code isn't under your control at all? Or is it partially under your control? For example, if this is generated code you could consider adding a build step to modify it...

people

See more on this question at Stackoverflow