Suppose you need to mock out RetrievalProcedures and that it has a method called GetPins you want to mock:
public partial class RetrievalProcedures { public virtual DataTable GetPins(System.Int32 numberOfPins) { using(DataAccessAdapter dataAccessProvider = new DataAccessAdapter()) { return GetPins(numberOfPins, dataAccessProvider); } } public virtual DataTable GetPins(System.Int32 numberOfPins, IDataAccessCore dataAccessProvider) { using(StoredProcedureCall call = CreateGetPinsCall(dataAccessProvider, numberOfPins)) { DataTable toReturn = call.FillDataTable(); return toReturn; } } ... }
You can create a partial class next to it as well as the interface you need and let the partial class implement the interface:
public interface IRetrievalProcedures { DataTable GetPins(System.Int32 numberOfPins); DataTable GetPins(System.Int32 numberOfPins, IDataAccessCore dataAccessProvider); }
partial class RetrievalProcedures : IRetrievalProcedures { }
The original class now implements the new interface and you can go forth and mock.
No comments:
Post a Comment