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 the following code throws ArgumentOutOfRangeException in ArrangeActAssert recorder (Isolator 5.2.1):
[Test, Isolated]
public void TestFoo()
{
   var foo = Isolate.Fake.Instance<Foo>();
   Isolate.WhenCalled(() => foo.Boo).WillReturn(10);

   Assert.AreEqual(10, foo.Boo);
}

public class Foo
{
   public int Boo;
} 
asked by andreister (3.4k points)

4 Answers

0 votes
Isolator AAA does not support faking fields - only properties.

You could change the class so the test would pass:
public class Foo
{
     public int Boo{ get; set;}
}
answered by dhelper (11.9k points)
0 votes
Yeah. Just wondering that if it does not support fields, there could have been a better error message :)

Thanks for the great job you guys do on the Isolator!
answered by andreister (3.4k points)
0 votes
Isolator AAA does not support faking fields - only properties.

You could change the class so the test would pass:
public class Foo
{
     public int Boo{ get; set;}
}


Has this changed in the latest release? (mocking fields )
answered by Rybolt (3k points)
0 votes
Unfotunately, the AAA API does not support faking fields, as @dhelper mentioned above.

However, the error message in the latest versions indicates it - if you try faking the field in Isolator v6 you'll get:

TypeMock.TypeMockException:
*** No method calls found in recording block. Please check:
* Are you trying to fake a field instead of a property?
answered by igal (5.7k points)
...