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
There seems to be a lot of mistakes in the cheatsheet and API sections.

For example:

ClassToIsolate
ClassToTest
MyType

And more objects don't exist.

Am I missing something? I have all the references in, or are the sections just wrong?

Thanks
Other than that, great product!
asked by GSS (2.8k points)

13 Answers

0 votes
I had used reflection in my tests to get the base class of a mocked object and mock static and non-static protected calls to the base class. How would I do that in AAA?
answered by trp (4.1k points)
0 votes
Also, I used to Verify all using MockManager.Verify is this action still possible in AAA?
answered by trp (4.1k points)
0 votes
Hi

I'll try to answer all the questions:
in AAA how do I make an instance of a class?

That is simple:
var fake = Isolate.Fake.Instance<ClassToFake>();


Which one is AAA? Natural Mocks or Reflective Mocks?

The Isolator has three API's Natural mocks and reflective mocks are older API's while Arrange Act Assert (AAA) is the new API.
In the code samples you posted I saw usage in reflective mocks API
like in the line:
 expected = MockManager.MockObject<ReadOnlyBO>().MockedInstance; 

And usage of AAA
 var fake = Isolate.Fake.Instance<GetBaseType>();  


I had used reflection in my tests to get the base class of a mocked object and mock static and non-static protected calls to the base class. How would I do that in AAA?

Why not fake the calls in base class directly?
in the example below I'm faking static protected method:
Isolate.NonPublic.WhenCalled(typeof(BaseClass), "ProtectedStaticMethod").WillReturn(10);

:arrow: Isolate.NonPublic is the entry point for all non public methods.
:arrow: Because the method is public we are using the type of the class as the first argument of WhenCalled
Faking instance protected method
var fake = Isolate.Fake.Instance<BaseClass>();
Isolate.NonPublic.WhenCalled(fake, "ProtectedInstanceMethod").WillReturn(10);

:arrow: Again Isolate.NonPublic is the entry point.
:arrow: Now the first argument for WhenCalled is the fake object we created in the previous line and not lambda expression.

Also, I used to Verify all using MockManager.Verify is this action still possible in AAA?

Sure,
Here's how to verify public method:
 Isolate.Verify.WasCalledWithAnyArguments(() => fake.SomeMethod()); 

Here's how to verify non public static method:
Isolate.Verify.NonPublic.WasCalled(typeof (BaseClass), "ProtectedStaticMethod");


Hope it clears things up.
answered by ohad (35.4k points)
...