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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:47:14+00:00 2026-05-28T00:47:14+00:00

My code is using a third party library that employ a singleton pattern deep

  • 0

My code is using a third party library that employ a singleton pattern deep down inside it. On first access, the library uses windows environment variables to identify a configuration folder from which it is loaded.

However, I want to run against different folders in different sets of unit tests. Ideally I would specify the configuration folder for every unit test class or somesuch.

The third party library is a huge object model and my code is simply a set of extension methods on top of of them. I can see no easy way of mocking out the entire library.

Is there any way that I can create a new appdomain per test class? I know that load tests has a setting for creating domains between running test assemblies. In my case that would be a lot of assemblies and I’m not quite sure if/how this setting can be set on unit test testrunner.

Alternatively, I am considering purchasing either Typemock Isolator or JustMock so that I can make the singleton return a “null”, resulting in the 3rd party library loading a new one. I’ve looked at the decompiled code and it appears that it could achieve the desired result. Of, course, there may be more “goodies” hidden there.

These are contrived approaches. What I really would like is to “flush” the complete appdomain between tests, test classes or test assemblies.

I am willing to sacrifice speed when automated tests need to switch configuration folders. The red-green-refactor cycle probably wont include multiple configuration folders.

Any suggestions on how to achieve this?

EDIT
I just discovered that different test assemblies will result in singletons being erased. Therefore, it is possible to organize test assemblies according to what configuration they run on instead of by dependency or problem domain which targeted by the tests.

  • 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-28T00:47:15+00:00Added an answer on May 28, 2026 at 12:47 am

    Spreading out in different test assemblies.

    Spreading the unit testing class into different test assemblies will result in new appdomains being created by the testrunner, and thus singletons will be erased.
    Therefore, it is possible to organize test assemblies according to what configuration they run on instead of by dependency or problem domain which targeted by the tests.


    This solution may not be for everyone, though, for the following reasons:

    This is in danger of creating a messy solution with an abundance of test projects (for the various test data). The resulting structure is contrary to standard pracitce of having unit tests organized per component and problem domain.

    I am not touching the data in the singleton. It is just a backing data reference library. A prime directive of unit tests is that they shall not affect each other or require a particular sequence.

    Another prime directive of unit tests is that they shall run fast. Luckily, I will not have to run against multiple test configurations in the normal red->green->refactor cycle. The larger suite of test assemblies will be regression tests.

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

Sidebar

Related Questions

We're using a third-party middleware product that allows us to write code in an
In a Java project, I am using a third-party library that loads some native
I'm using a COM object from a third party library that generates periodic events.
I'm using a third party library class that has the following (abbreviated) method: public
I'm using a third-party COM library from C#. There are get/set methods that take
I'm using Autoconf to build my c++ project. It uses third party code which
I'm using third party library which compiled one week ago. Today I sat down
I am using a third party .Net dll in my code and when I
I've come across an issue with using a third party library, and am not
My app links to a third party static library which without source code and

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.