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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:46:53+00:00 2026-06-08T16:46:53+00:00

I have a separate class library that I’m using for all of my unit

  • 0

I have a separate class library that I’m using for all of my unit testing (using nunit). In the test project, I have a helper class that creates test objects for me. When setting up these objects, I need to set some values that I have marked as internal. The reason I do this is because these objects are actually part of a work flow so I would only otherwise be able to achieve these property states by actually going through the workflow which kind of kills the idea of unit testing.

For instance, the method I’m testing first. It checks to see if a certain approval was made and if it does, it moves it to the next step in the chain (or rather, it checks to see if the next approval was received, and so on down the chain). If it doesn’t not, it reassigns it to the person from whom the approval is needed.

So what I do is create a test ticket that is in a certain stage of this process. For instance, the first test runs the method where the first approver has not approved, and checks to ensure that it gets reassigned to that person. The next test will run it where the approver HAS approved and ensures that it moves on down the tree.

The problem that I obvious face is that the test classes are in a different namespace, so I can’t hit the internal properties. I’m not sure if there’s a work around for this or if maybe I’m missing some other fundamental that is backing me into this corner (design smell?). I realize that you generally only want to write tests for the public api, but part of my tests require that I do some setting of private fields.

Any 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-06-08T16:46:54+00:00Added an answer on June 8, 2026 at 4:46 pm

    You could make use of the InternalsVisibleTo attribute to specify that your UnitTest assembly can access internal properties of that class.

    This tightly couples your test and ‘real’ assembly but this should get you working.

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

Sidebar

Related Questions

Let's say you have a class library project that has any number of supplemental
I have created a separate class library to hold all my model objects. This
I have a few classes in the class library (separate assembly). I referenced it
I have a class library which I maintain in it's own project/solution. It contains
I have a library project which contains an abstract class, let's say ClassA .
I have a XAML page in a separate Windows Phone class library. The library
Say, for example, I have many web applications using the same class library compiled
I have made a .NET class library in C# that initializes some logging, sent
I have written my application to be a class library that is launched by
I have an ASP.NET website project that until recent had all code in App_Code

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.