This is a migrated thread and some comments may be shown as answers.
Mock Extension Method Throws "Object reference not set to an instance of an object."
1 Answer 45 Views
This is a migrated thread and some comments may be shown as answers.
Erik
Top achievements
Rank 1
Erik asked on 30 Apr 2012, 03:09 PM
I am simply trying to mock an extension method on an Enum and no matter how I set it up I always seem to get a "Object reference not set to an instance of an object." error. Here is my code:

var invalidType = new MyEnum();
Mock.Arrange(() => invalidType.ToType()).Returns((System.Type)
null);

The extension method (ToType) is just a switch statement that maps enum values to Types. I also tried using a mock for the invalidType.

1 Answer, 1 is accepted

Sort by
0
Ricky
Telerik team
answered on 01 May 2012, 11:34 PM
Hi Erik,

Thanks again for reporting the issue.

I was able to reproduce the problem and make the fix. Should you need a build urgently, please open a support ticket where I will send the updated version of Telerik.JustMock.dll that should solve your issue.

I also created a task which you can follow here:
http://www.telerik.com/support/pits.aspx#/public/justmock/10937


Kind Regards
Mehfuz 
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Asked by
Erik
Top achievements
Rank 1
Answers by
Ricky
Telerik team
Share this question
or