I have a class that inherits from an abstract base class. I am trying to verify that a specified protected method in the base class is called twice and I'd like to verify that the parameters passed are specific values (different for each call).
I was hoping that I'd be able to use Protected
with either Expect
or Verify
, but seemingly I've missed what can be done with these methods.
Is what I'm attempting possible with moq?
UPDATE: An example of what I'm trying to do:
class MyBase
{
protected void SomeMethodThatsAPainForUnitTesting(string var1, string var2)
{
//Stuf with file systems etc that's very hard to unit test
}
}
class ClassIWantToTest : MyBase
{
public void IWantToTestThisMethod()
{
var var1 = //some logic to build var 1
var var2 = //some logic to build var 2
SomeMethodThatsAPainForUnitTesting(var1, var);
}
}
Essentially I want to test the way the variables var1 and var2 are created correctly and passed into SomeMethodThatsAPainForUnitTesting
, so essentially I want to mock out the protected method, verify that it was called at least once and that the parameters were all passed correctly. If this was calling a method on an interface it would be trivial, but I'm coming unstuck with a protected method.
I can't easily change the design as it's brown field development and I'm not the only class calling the method.