chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
We're still on version 5.2.3

This test is against code that uses Microsoft's Pattern & Practice UIP (User Interface Process) block.

The error from Isolator is:
*** Cannot use Isolate.Verify on a sattic method without first setting static method behavior using Isolate.Fake.StaticMethods().

The test is this:
[code]
Navigator navigator = Isolate.Fake.Instance<Navigator>(Members.ReturnRecursiveFakes);
DerivedController target = new DerivedController(navigator);

Isolate.WhenCalled(() => target.State["XYZ"]).WillReturn(new SomeObjectRequiredForMethodUnderTest());

target.MethodUnderTest();

Isolate.Verify.WasCalledWithExactArguments(() => target.State.Remove(target.SomeConstant));

----

So first, State.Remove is an instance method, not a static method - I imagine it's something underlying though, so second, I fake static constructors and methods on both State and Navigator and no matter what I can't get this error to go away.

Any ideas? If the message included the name of the object that static methods needed to be faked on, that would make life a lot easier (or if it just went ahead and faked it for me).

Thanks, Brian
asked by boo (21.8k points)

1 Answer

0 votes
I figured it out. The first part I remember getting me before.

Instead of using a constant from the class in my expectation I need to set a local variable to the constant variable and then use the local variable in the expectation.

The second part, which I don't understand, is that I had to add:
Isolate.WhenCalled(() => target.State.Remove("")).IgnoreCall()

Without this method it was saying that the method was expected but not being called. I'd like to understand why it wasn't working without it, but at this point I'm happy because I'm green now.
answered by boo (21.8k points)
...