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 8895793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:52:49+00:00 2026-06-14T23:52:49+00:00

I want to unit test a class that reads the power information. I have

  • 0

I want to unit test a class that reads the power information.
I have a private readonly variable which i assign a value from System.Windows.SystemInformation.PowerStatus and i can use reflection to change this no problem but…

System.Windows.PowerStatus does not have a public constructor and won’t let me inherit from it to derive a testPowerStatus class i can use with my tests.

I want to be able to override the getter for BatteryLifePercent and BatteryLifeRemaining property so i can test that the correct behavior happens when these are certain values.

Is there anyway i can do this? or is this impossible?

  • 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-06-14T23:52:51+00:00Added an answer on June 14, 2026 at 11:52 pm

    The “right” way to do this is to create an abstraction layer. You should create a IPowerInfoProvider interface, and then create a stub implementing the interface for tests, and another implementation providing real power info.

    Your BL should only know about the IPowerInfoProvider interface.

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

Sidebar

Related Questions

I have a method CreateAccount(...) that I want to unit test. Basically it creates
I have the below class I want to unit test: public class MyClass {
I want to write unit test for a class that contains linq to sql
I have a pseudo random number generator (PRNG) class that I want to unit
I have an EJB which I want to unit test its public methods. I
I have a class library I want to unit test using Microsofts unit test
I want to create a unit test for integration testing. What class should I
I want to Unit Test my application which use MSMQ but i found no
I want to write a unit test for a Django manage.py command that does
I am trying to unit test a class that does SAX parsing and creates

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.