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
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
Hi - I'm attempting to fake a public interface and setup the return value of a method call as follows;

IMainForm form = Isolate.Fake.Instance<IMainForm>();
MainFormPresenter presenter = new MainFormPresenter(form);
Isolate.WhenCalled(() => form.ConfirmCalculate()).WillReturn(false);

The test fails on the line in bold with the following message;

Test method TypeMock.PresenterTests.TestOverriddenCalculateConfirmWithErrorsSupressed threw exception: TypeMock.TypeMockException:
*** No method calls found in recording block. Please check:
* Are you trying to fake a field instead of a property?
* Are you are trying to fake mscorlib type?.

If I replace the line in bold with the following, it works Ok;

Isolate.NonPublic.WhenCalled(form, "ConfirmCalculate").WillReturn(false);

Is this expected behaviour? I'd expect I could use the original typesafe syntax when faking an interface.
asked by stephencampling (3k points)

3 Answers

0 votes
Hello Stephen,

Are you getting the error on the WhenCalled line?

I'd like to try and help you resolve this. Could you please post the following details:

1. What version of Isolator are you using?
2. Could you post the rest of the test?
3. Do you have [Isolated] attribute decorating your test?

Also, it would be great if you could manage to send us a reproduction project to support at typemock.com

Thanks a lot!
answered by igal (5.7k points)
0 votes
Hi - thanks for your response.

In answer to your questions;

Yes the error is occuring on the WhenCalled line.

1) I'm using isolator version 6.0.4.0.
2) The full test method is;
[TestMethod]
public void TestOverriddenCalculateConfirmWithErrorsSupressed()
{
IMainForm form = Isolate.Fake.Instance<IMainForm>();
MainFormPresenter presenter = new MainFormPresenter(form);
Isolate.WhenCalled(() => form.ConfirmCalculate()).WillReturn(true);
Isolate.WhenCalled(() => form.SupressError).WillReturn(true);
presenter.Calculate();
Isolate.Verify.WasCalledWithAnyArguments(() = > form.ConfirmCalculate());
Assert.IsInstanceOfType(presenter, typeof(MainFormPresenter));
}
3) I have added the [isolated] attribute to the test class, however, I have also tried adding it to the test method with the same results.

I will send the project and relevant test through to the support email address now.

Many thanks
Steve.
answered by stephencampling (3k points)
0 votes
Hi again Stephen,

I sent you a reply via the support email. The problem was that you used "TypeMock" as the name of your test project, and this caused confusion during faking.
answered by igal (5.7k points)
...