Sorry about that, it always sounds clear when writing it out.
Hopefully this is more clear.
A WebService has a webmethod DoSomeWork, which creates a single LegacyObject. This Legacy object has methods, none are static and non void.
bool VerifyRules()
bool Search("sqlString");
bool obj.Save();
So basically the web method looks something like this, just trying to illustrate that these methods are all in the mocked LegacyObject itself. Things like the VerifyRules, has to be mocked because it has a .config file that acts like a DI framework to load rule assemblies. Search loads up .config files for sql conn strings and so forth..its all pretty nasty.
So at the highest level...if VerifyRules failes..the system should not save. That is the sort of behavior testing I am trying to capture.
[WebMethod(true)]
public bool DoSomeWork(){
if (obj.VerifyRules()){
if(obj.Search("sqlString"){
return obj.Save();
}
}else{return false;}
}
LegacyObject is part of a huge hierarchy with many instance members of items like HttpContext and mutators for HttpSession, Database methods..all rolled into one. I can't call original without mocking a huge number so I wanted AAA syntax to RecursivlyMock items.
My test was setup like the following.
LegacyObject fakeObj = Isolate.Fake.Instance<LegacyObject>(Members.ReturnRecursiveFakes);
Isolate.WhenCalled(() => LegacyObject.VerifyRules).WillReturn(true);
Isolate.WhenCalled(() => LegacyObject.Save).WillReturn(true);
Isolate.WhenCalled(() => LegacyObject.Search("sqlString")).WillReturn(true);
//Did the isolate.swap next instance
//Called real code
CustWebService custWebService = new CustWebService();
//Call the actual method.
custWebService.DoSomeWork();
\These work fine, I can even say WasNotCalled to make this fail and play around
Isolate.Verify.WasCalledWithAnyArguments(()=>fakeObj.VerifyRules());
Isolate.Verify.WasCalledWithAnyArguments(()=>fakeObj.Save());
\no matter what I try here, this line causes a failure
Isolate.Verify.WasCalledWithAnyArguments(()=>fakeObj.Search("sqlString"));
Mind you, when I can get this to work. I will be setting expectations to return false and do a verify.wasNotCalled for an additional test and true to make sure it is saving.
I guess my issue is that I have mocked LegacyObject, and everything in it should be mocked, and when I call verify on any method on that object that I have set up expectations for: if they are parameterless, they work. If it has parameters, it gives me the error.
I hope that makes things more clear, and thanks for your time and effort.