Code:
public class MyClass
{
public bool MethodX(long parameterX)
{
bool retVal = false;
...code...
if (this.PropertyX != null && this.PropertyX == parameterX)
{
PrivateMethodY();
}
...code...
return retVal;
}
private void PrivateMethodY()
{
...code...
}
public long PropertyX
{
get
{
...Code...
}
set
{
...Code...
}
}
}
In the given scenario above, I want to test if PropertyX != parameterX, call to PrivateMethodY should not be made.
Test:
[TestMethod, VerifyMocks]
public void MethodXTest()
{
MyClass_Accessor target = new MyClass_Accessor();
using (RecordExpectations r = RecorderManager.StartRecording())
{
r.ExpectAndReturn(target.PropertyX, (long)11);
r.FailWhenCalled(target.PrivateMethodY());
}
Assert.IsTrue(target.MethodX(10));
}
Since PrivateMethodY() retruns void, FailWhenCalled can not be used as it takes 'object' parameter.
I want to know if there is a way to test this and test will fail if a call is made to 'PrivateMethodY()'
Thank you,
Vikas