Testing a Protected Method is called

3 posts, 0 answers
  1. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 11 May 2015 Link to this post

    I've found a couple of articles about testing protected methods and have written the appropriate code to do so.

    However, now I want to test my class, which includes a public abstract method, to ensure, when the abstract method is called in this particular implementation, that one or more protected methods are called. Something like this ...

    01.public abstract class MyBaseClass
    02.{
    03.    protected void Foo(){ /* stuff */ }
    04.    protected void Bar(){ /* stuff */ }
    05.     
    06.    public abstract void Stuff();
    07.}
    08. 
    09.public class MyClass : MyBaseClass
    10.{
    11.    public override void Stuff()
    12.    {
    13.        Bar();
    14.    }
    15.}

     

    In this trivial example I want my test to ensure that Bar() is called.

     Can I actually do this?

  2. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004
  3. DevCraft R3 2016 release webinar banner
  4. Stefan
    Admin
    Stefan avatar
    198 posts

    Posted 12 May 2015 Link to this post

    Hello Stuart,

    I'm glad that the documentation proved useful to you.

    Regards,
    Stefan
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top