Let's say I have a repository of functions. These functions work with business objects within a database, CMS or other third party API. For example, my repository interacts with virtual files and documents in a document management system. I want to be able to implement a simulation mode in my repository such that when I execute commands, I want to see the result of it without it actually doing anything. This is to reduce the risk of someone executing a series of commands in my repository and doing something dangerous. I want them to first see the output and confirm before executing.
My question is, what are some good patterns to implement a simulation mode for a repository? I can think of a few off the top of my hat:
Wrap all business objects in another class, such that when you would call File.Delete, your actually calling the wrapper class and it checks in simulation mode is enabled. The problem is that many third party libraries and SDKs don't let you subclass their business objects. How would you pass in the the simulation mode (everytime an object is instantiated?).
Another option would be to implement a SimulatedRepository. However, I don't want to duplicate any existing code in the repository. Meaning, I don't want to simulate everything to the point that it does nothing, I only want to simulate create, update and delete commands, not the business logic. Perhaps I need to implement another layer in my application?
Suggestions would be appreciated. I also wonder if this design philosophy is popular in most enterprise environments and how its done. I would think that allowing administrators to run a simulation and measure results before actually executing them is vital in a mission critical scenario where you are working with another client's data.