Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 226829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:32:52+00:00 2026-05-11T19:32:52+00:00

I can’t find any info on whether it can do this. I have a

  • 0

I can’t find any info on whether it can do this.

I have a couple of protected methods inside the abstract class and want to test these.

I don’t want to inherit from the class and test its implementation (besides thats technically not strictly unit testing, also VS2008 won’t let you test inherited methods).

I would like to solve this problem within the context of the integrated unit tests … I am aware that nUnit for example will allow you to do this.

any thoughts? suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:32:52+00:00Added an answer on May 11, 2026 at 7:32 pm

    VS2008 can test private and protected methods inherited from base classes, even abstract ones.

    If you are happy testing this way then right click on the code to be tested and create unit tests.

    Here’s an example of a piece of code which I am using to test a private, inherited function, from an abstract class:

        [TestMethod()]
        [DeploymentItem("PA Manager.dll")]
        public void GetNextScheduledTimeTest4()
        {
            TimeWheel timeWheel = new TimeWheel(1000, null);
            AnnouncementSchedule schedule = new AnnouncementSchedule();
            schedule.StartDate = DateTime.UtcNow.Date - TimeSpan.FromDays(1);
            schedule.StartTime = DateTime.Parse("09:00:00");
            schedule.EndDate = DateTime.UtcNow.Date;
            schedule.EndTime = DateTime.Parse("14:30:00");
            schedule.Interval = DateTime.MinValue + TimeSpan.Parse("01:00:00");
            schedule.DaysValid.ValidDay = new Day[7];
            schedule.DaysValid.ValidDay[0] = Day.Monday;
            schedule.DaysValid.ValidDay[1] = Day.Tuesday;
            schedule.DaysValid.ValidDay[2] = Day.Wednesday;
            schedule.DaysValid.ValidDay[3] = Day.Thursday;
            schedule.DaysValid.ValidDay[4] = Day.Friday;
            schedule.DaysValid.ValidDay[5] = Day.Saturday;
            schedule.DaysValid.ValidDay[6] = Day.Sunday;
    
            //// test for the next interval time NOT being valid, but the time period and day for the schedule is.
    
            PaAnnouncementSchedule paAnnouncementSchedule = new PaAnnouncementSchedule(timeWheel, schedule);
            PrivateObject param0 = new PrivateObject(paAnnouncementSchedule); 
            PaAnnouncementSchedule_Accessor target = new PaAnnouncementSchedule_Accessor(param0); 
            DateTime currentTime = DateTime.Parse("14:07:00");
            DateTime actual;
            DateTime expected = DateTime.MaxValue;
            actual = target.GetNextScheduledTime(currentTime);
            Assert.AreEqual(expected, actual, "Expected time to be DateTime.MaxValue");
        }
    

    Out of that lot the important part is:

    PaAnnouncementSchedule paAnnouncementSchedule = new PaAnnouncementSchedule(timeWheel, schedule);
    PrivateObject param0 = new PrivateObject(paAnnouncementSchedule); 
    PaAnnouncementSchedule_Accessor target = new PaAnnouncementSchedule_Accessor(param0);
    

    This allows me to access the private inherited function “GetScheduledTime”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of
I have a jquery bug and I've been looking for hours now, I can't
Does anyone know how can I replace this 2 symbol below from the string
Can I use the following across all browsers? <a href=# onclick=doSomething()>Click here.</a> Is this
Can anyone tell me what's wrong with this robots.txt? http://bizup.cloudapp.net/robots.txt The following is the
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) I have a Rails
Can someone explain to me how exactly the NSTimer behavior is? Basically I want
I have some data like this: 1 2 3 4 5 9 2 6
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Can someone point to me or explain if this is true, you must not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.