Home:ALL Converter>Mocking calls to SQL Server Stored Procedures?

Mocking calls to SQL Server Stored Procedures?

Ask Time:2016-03-10T22:50:20         Author:Mr. Boy

Json Formatter

I am implementing an interface into a C# class, whose entire job is basically just to call some T-SQL stored procedures and return the data. Other implementations of the interface may obtain data through web-services, reading files, etc, so to test this particular class I'd ideally mock an SQL Server database and its procedures.

I'm not sure if this is feasible. I've seen tools like RhinoMock used to mock database tables but since the entire purpose of my code is to talk to a DB, can I mock the entire DB or is that a bit of a waste of time? I'd ideally like a way to transparently provide a replacement for having a real DB so local testing can be done, making real stored-procedure calls against a fake DB.

Author:Mr. Boy,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/35919785/mocking-calls-to-sql-server-stored-procedures
yy