i want to test the bellow method
private DbConnection GetConnection()
{
var dbProviderFactory = DbProviderFactories.GetFactory(_name);
try
{
var dbConnection = dbProviderFactory.CreateConnection();
if (dbConnection == null) return null;
dbConnection.ConnectionString = _connectionString;
return dbConnection;
}
catch (Exception)
{
return null;
}
}
in this method mainly im doing to get dbresource details and connection status the code is working fine and now im facing issues with unit test . wanna write test cases for this peace of code , in that i used DbProviderFactories , i want mock the DbProviderFactories class since its a static class and i cant pass through constructor and i cant inject also . how can i test my code / how can make mock for DbProviderFactories?
TIA
Aucun commentaire:
Enregistrer un commentaire