Last active
July 7, 2017 07:39
-
-
Save WilliamBerryiii/3c1eb22fc963cffe6cbf to your computer and use it in GitHub Desktop.
Simple example of testing a stored procedure return code parameter with Moq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const string RETURN_CODE_NAME = "@return_code"; | |
const int SP_RETURN_VALUE = 0; | |
Dictionary<string, SqlParameter> parameterList = null; | |
_mockSqlExecutor = new Mock<ISqlExecutor>(); | |
_mockSqlExecutor.Setup(mdm => | |
mdm | |
.ExecuteNonQuery(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<Dictionary<string, SqlParameter>>())) | |
.Callback( | |
(string conn, string procName, Dictionary<string, SqlParameter> plist) => | |
{ | |
parameterList = plist; | |
plist["RETURN_CODE_NAME"].Value = SP_RETURN_VALUE; | |
}); | |
//Do Stuff With Mock Sql Executor | |
Assert.AreEqual(SP_RETURN_VALUE, (int)(parameterList["RETURN_CODE_NAME"].Value)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Can I ask for what is the library ISqlExecutor belongs to?