For my tests, I need to mock the data client, in my case it's Oracle.
I created my level of data access so that this can be transmitted:
public static Int32? GetUserRoleId(string userName, OracleConnection cn, OracleCommand cmd)
I use Moq, although I can switch to another framework if necessary, and when I go to create Mock objects like this:
Mock<OracleConnection> mockOracleConnection = new Mock<OracleConnection>(); Mock<OracleCommand> mockOracleCommand = new Mock<OracleCommand>();
I get this error:
Disclaimer: System.ArgumentException: The type for bullying must be an interface or an abstract or unsealed class.
Conclusion: It was easier than I thought! Just make fun of the function of the DAL layer as follows:
mockDao.Setup(a => a.GetUserRoleId(userName, It.IsAny<OracleConnection>(), It.IsAny<OracleCommand>())).Returns(1);
c # oracle unit-testing moq
Lucas b
source share