Mocking sealed class

1,031 views
Skip to first unread message

snickers5x5

unread,
Feb 2, 2012, 1:30:37 PM2/2/12
to NSubstitute
Is this possible? I know most mocking frameworks cannot do this other
than TypeMock I believe.

snickers5x5

unread,
Feb 2, 2012, 1:31:48 PM2/2/12
to NSubstitute
Can you mock sealed classes? I know that most mocking frameworks
cannot other than TypeMock from what I've found.

Steve Nickerson

unread,
Feb 2, 2012, 1:39:20 PM2/2/12
to NSubstitute
nm answering this. i found another post that covered it.  any plans to support in the future?

David Tchepak

unread,
Feb 2, 2012, 6:15:58 PM2/2/12
to nsubs...@googlegroups.com
Hi Steve,

We've no plans to support this at the moment. You could try TypeMock, JustMock, or Moles frameworks, using IL re-writing to un-seal classes, or wrapping the sealed class in your own type.

As an aside, I've run into troubles mocking types I don't own before: http://davesquared.net/2011/04/dont-mock-types-you-dont-own.html. Might be worth trying integration tests over the boundary between your code and the sealed type?

Regards,
David


--
You received this message because you are subscribed to the Google Groups "NSubstitute" group.
To post to this group, send email to nsubs...@googlegroups.com.
To unsubscribe from this group, send email to nsubstitute...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nsubstitute?hl=en.

Reply all
Reply to author
Forward
0 new messages