Re: [nsubstitute] Accessing protected members

1,511 views
Skip to first unread message

David Tchepak

unread,
Jun 8, 2012, 9:38:15 PM6/8/12
to nsubs...@googlegroups.com
Hi Bill,

NSubstitute can't check calls to protected methods. 

Maybe try manually overriding the class and trap the call yourself in that subclass? (This is known as the self-shunt pattern: http://c2.com/cgi/wiki?SelfShuntPattern)

Regards,
David


On Thu, Jun 7, 2012 at 3:45 AM, Bill Sorensen <bald...@gmail.com> wrote:
I'm doing a partial mock on a class with the following method:

  protected virtual void Dispose(bool disposing)

How do I check that this call was received?

--
You received this message because you are subscribed to the Google Groups "NSubstitute" group.
To view this discussion on the web visit https://groups.google.com/d/msg/nsubstitute/-/f59XwiU01MwJ.
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.

Bill Sorensen

unread,
Jun 13, 2012, 1:16:05 PM6/13/12
to nsubs...@googlegroups.com
Thank you!

I did work around it. This would be a nice feature to include, though, along the lines of Moq.Protected().


On Friday, June 8, 2012 8:38:15 PM UTC-5, David Tchepak wrote:
Hi Bill,

NSubstitute can't check calls to protected methods. 

Maybe try manually overriding the class and trap the call yourself in that subclass? (This is known as the self-shunt pattern: http://c2.com/cgi/wiki?SelfShuntPattern)

Regards,
David
On Thu, Jun 7, 2012 at 3:45 AM, Bill Sorensen <bald...@gmail.com> wrote:
I'm doing a partial mock on a class with the following method:

  protected virtual void Dispose(bool disposing)

How do I check that this call was received?

--
You received this message because you are subscribed to the Google Groups "NSubstitute" group.
To view this discussion on the web visit https://groups.google.com/d/msg/nsubstitute/-/f59XwiU01MwJ.
To post to this group, send email to nsubs...@googlegroups.com.
To unsubscribe from this group, send email to nsubstitute+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages