Configuration via Typemock Interception

A while ago Udi Dahan wrote that he’d like a way to configure objects by just setting property values on an object. those “setters” will be intercepted and saved to a some config object (or container) for the future use of the application.

Udi turned to me a while ago and asked if perhaps typemock could be used to do this. an unusual scenario for a mocking framework, but a valid one for an AOP framework (which typemock is sort of)

It lost my mind after a while but today I talked with udi again, and came up with a simple solution to his problem. Here is a simple class that can be used like this:

 

  • Paul

    Does this mean in type mock you can mock and stub classes without needing an interface or abstract class?

  • RoyOsherove

    yep!

  • Gil Zilberfeld

    And,

    That’s also true for sealed classes and mocking and stubbing static methods.