I have a legacy application which should be refactored and made testable. It consists of C# code separated into model and view code. The C# model code essentially exposes a public API with high level CRUD methods.
In itself the C# is doing rather little but delegates the actual work to SQL Server stored procedures. The C# code mostly concerns itself with configuring a large array of parameters which then directs what to process in the SQL database - there is very little input/output as such.
The bulk of the processing occurs in these stored procedures. Because this is hundreds of thousands of database rows, it does not seem practical to convert this all to an ORM approach (where essentially the data would be loaded into memory in C#) - the processing really should stay on the SQL Server.
My question is how to unit-test something that. The obvious choice seems to be:
- write unit tests for SQL Server procedures
- write unit tests for the C# code (mocking SQL procedures)
Then one will have to write integration tests which tests the overall functionality. Since there is so little functionality in the C# code (some are mere stubs calling the SQL proc), does this even have any value in testing? It sounds somewhat redundant to me.
It sounds I should do only integration testing which allows me to use better testing frameworks than what I can do within SQL Server (I could pretend they really are unit tests by ignoring my knowledge of having an SQL backend) - but it does violate the "unit testing" methodology.
What would be the most workable solution for this scenario?
Edit: Most of the C# methods look similar to the sample given below - some do a few lines more processing, but in essence it boils down to ADO.NET code:
public void LogImport(int PeriodID, String orgCode, int userID) { TryOpenSQLConnection("ImportSQL.LogImport"); try { SqlCommand cmd = new SqlCommand("dbo.LogImport", sqlCn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@periodID", PeriodID); cmd.Parameters.AddWithValue("@orgCode", orgCode); cmd.Parameters.AddWithValue("@userID", userID); cmd.ExecuteNonQuery(); } catch (Exception ex) { throw new DataException(" ... ") } }