Mock Extension Method Throws "Object reference not set to an instance of an object."

2 posts, 0 answers
  1. Erik
    Erik avatar
    13 posts
    Member since:
    May 2011

    Posted 30 Apr 2012 Link to this post

    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)

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

    Posted 01 May 2012 Link to this post

    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:

    Kind Regards
    the Telerik team

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

Back to Top