Function definition:
function New-SqlCommand
{
return New-Object ("System.Data.SQLClient.SQLCommand")
}
Implementation:
$deleteCmd = New-SqlCommand
$deleteCmd.Connection = $Connection
$deleteCmd.Transaction = $Transaction
How can I mock this New-SqlCommand Object?
I was trying something on these line:
$NewSqlCommand = @"
public class MockSqlCommand
{
public System.Data.SqlClient.SqlConnection Connection { get; set; }
public System.Data.SqlClient.SqlTransaction Transaction { get; set; }
public void ExecuteNonQuery() {}
}
"@
Add-Type -TypeDefinition $NewSqlCommand -ReferencedAssemblies System.Data -Language CSharp -Debug
$NewSqlCommand = New-SqlCommand MockSqlCommand
but this approach didn't worked for me.