I'm writing a test in Visual Basic .NET in Visual Studio 2012. In a particular Stub I'm sure all the arguments match but yet it only gets executed if I add IgnoreArguments
to it, but since I need to have other similar stubs for that same method this is not acceptable for production.
I can't post a code sample (well, I could, but it would need to be really big in order to be useful). But it might suffice if I tell you that it's a request in the shape of:
Dim request As IMyRequest = MyService.CreateRequest(obj1, obj2, list1,
int1, int2, bool1, bool2, bool3, string1, bool4, int3)
And my Stub looks like:
_myService.Stub(Function(x) x.CreateRequest(obj1, obj2, list1,
int1, int2, bool1, bool2, bool3, string1,
bool4, int3)).IgnoreArguments.Return(myRequest)
And _myService
is a mock defined in the TestInitialize
method like so:
_myService= Mock.Get(Of IMyService)()
I've checked and all the values match. There's also another very similar test with a very similar call (which works perfectly without the IgnoreArguments
clause) that I've used as sample, so I'm at a loss as to why this isn't working.
Q: I'm sorry to ask such a vague question, but can anyone think of anything I might be missing to check?
I'll clarify whatever doesn't make sense. Thanks for the read.
EDIT: whelp, it turned out (after yet another pair of eyes glanced at the code) that indeed the type of one of the parameters was off. yay for disgustingly similar class names I'm not sure how to close this, so just let it die. Thanks and sorry for robbing you of your time.
I assume you are mocking the service here for your test. Object equality on the stub is probably what is causing it to not get called. Without more information it is hard to say but that is the first thing I would look at.