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

  • Home
  • SEARCH
  • 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 53451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:03:56+00:00 2026-05-10T17:03:56+00:00

I have a class holding complex scientific computations. It is set up to only

  • 0

I have a class holding complex scientific computations. It is set up to only allow a user to create a properly instantiated case. To properly test the code, however, requires setting internal state variables directly, since the reference documents supply this data in their test cases. Done improperly, however, it can invalidate the state.

So I must have the ability, a member function, to set internal variables from the unit test programs. But I want to strongly discourage normal users from calling this function. (Yes, a determined user can muck with anything… but I don’t want to advertise that there is a way to do something wrong.)

It would be nice to be able to tell Intellisense to not show the function, for instance.

The best solution I have at the moment is to just name the function something like: DangerousSet().

What other options do I have?

Follow-Up

I found Amy B’s answer most useful to my situation. Thanks!
Mufasa’s suggestion to use reflection was great, but harder to implement (for me).
Chris’ suggestion of using a decorator was good, but didn’t pan out.
BFree’s suggestion on XML is also good, and was already in use, but doesn’t really solve the problem.

Finally, BillTheLizard’s suggestion that the problem is in the source documents is not something I can control. International experts publish highly technical books and journal articles for use by their community. The fact that they don’t address my particular needs is a fact of life. There simply are no alternative documents.

  • 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. 2026-05-10T17:03:56+00:00Added an answer on May 10, 2026 at 5:03 pm

    Suppose you want to test this object by manipulating its fields.

    public class ComplexCalculation {     protected int favoriteNumber;     public int FavoriteNumber     {         get { return favoriteNumber; }     } } 

    Place this object in your test assembly/namespace:

    public class ComplexCalculationTest : ComplexCalculation {     public void SetFavoriteNumber(int newFavoriteNumber)     {         this.favoriteNumber = newFavoriteNumber;     } } 

    And write your test:

        public void Test()     {         ComplexCalculationTest myTestObject = new ComplexCalculationTest();         myTestObject.SetFavoriteNumber(3);         ComplexCalculation myObject = myTestObject;          if (myObject.FavoriteNumber == 3)             Console.WriteLine('Win!');      } 

    PS: I know you said internal, but I don’t think you meant internal.

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

Sidebar

Ask A Question

Stats

  • Questions 75k
  • Answers 75k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Do something like this..I've tested it in my own little… May 11, 2026 at 2:53 pm
  • added an answer You can set access rules for ASP.NET or WCF web… May 11, 2026 at 2:53 pm
  • added an answer Put it at the root level of one of your… May 11, 2026 at 2:53 pm

Related Questions

This one is fairly complex, hopefully I can make this clear enough for somebody
I have a templated class defined (in part) as template <class T> MyClass {
I have a cache which has soft references to the cached objects. I am
I need help getting my head around the difference between my current OOP notion

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.