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
I have some code that worked in version 2.2 but its not working in 2.3.

The code is:
Mock mockDatabase = MockManager.Mock(typeof(Database));
mockDatabase.ExpectUnmockedCall("Get");

Get is a static method, but I don't think that should matter.

If I remove this mock then the "Get" procedure will actually run as expected, but the problem is that I need to mock another method besides "Get", so that is why I need to mock this object and let "Get" run as an unmocked call.

When the operation runs while mocked, I get an Object null reference when calling "Get" on Database.
asked by jnapier (9.6k points)

2 Answers

0 votes
I have some code that worked in version 2.2 but its not working in 2.3.

The code is:
Mock mockDatabase = MockManager.Mock(typeof(Database));
mockDatabase.ExpectUnmockedCall("Get");
When the operation runs while mocked, I get an Object null reference when calling "Get" on Database.

Hi,
This is probrably a bug :twisted:, the code should work, we will check it, fix it and post the fix (Read on to see a workaround)

I need to mock another method besides "Get", so that is why I need to mock this object and let "Get" run as an unmocked call.

From what I understand you don't really need to use ExpectUnmockedCall, if you are mocking other methods and you are not in Strict mode, all non registered expectations are unmocked.
The only times that you should use Unmocked is:
1. You are in Strict Mode.
2. You want to Mock a Method AFTER it runs normally 1 or more times.
3. You want to verify the arguments passed.
4. You are using a Dynamic Mock of an Interface (This is because there is no real code in the class created that implements the Interface)

:?: Does your test work if you remove the expecatation?
answered by scott (32k points)
0 votes
Mock mockDatabase = MockManager.Mock(typeof(Database));


Hi,
What class Is Database? Is is proprietary?
Please send the log of the Database.Get method.
See the First Topic of the Bugs Forum to see how to create a log, and send the Database.Get part.
answered by scott (32k points)
...