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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:29:38+00:00 2026-05-26T14:29:38+00:00

I have a bunch of unit tests in unit test class. When I run

  • 0

I have a bunch of unit tests in unit test class.

When I run each one individually, they all pass, but when I run them all at the same time, the first one passes and the rest fail:

System.ArgumentException: An item with the same key has already been
added

Could anyone tell me why? And how I need to remedy the error?

Sample:

 public TestContext TestContext
    {
        get
        {
            return testContextInstance;
        }
        set
        {
            testContextInstance = value;
        }
    }

    #region Additional test attributes
    #endregion

    /// <summary>
    ///A test for SplitTdsName
    ///</summary>
    [TestMethod()]
    public void SplitTdsNameTest_SimpleValidName1()
    {            
        string tdsName = "Mr Daniel Trunley";
        MemberName expected = new MemberName("Mr", "Daniel", "Trunley");
        MemberName actual;
        actual = TdsTransformer.SplitTdsName(tdsName);
        Assert.AreEqual(expected, actual);            
    }

    /// <summary>
    ///A test for SplitTdsName
    ///</summary>
    [TestMethod()]
    public void SplitTdsNameTest_SimpleValidName2()
    {
        string tdsName = "Mr Daniel George Trunley";
        MemberName expected = new MemberName("Mr", "Daniel George", "Trunley");
        MemberName actual;
        actual = TdsTransformer.SplitTdsName(tdsName);
        Assert.AreEqual(expected, actual);
    }

    [TestMethod()]
    public void SplitTdsNameTest_SimpleValidName3()
    {
        string tdsName = "Daniel George Trunley";
        MemberName expected = new MemberName("", "", "Daniel George Trunley");
        MemberName actual;
        actual = TdsTransformer.SplitTdsName(tdsName);
        Assert.AreEqual(expected, actual);
    }

The remaining tests are all of the same type.

  • 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-26T14:29:39+00:00Added an answer on May 26, 2026 at 2:29 pm

    Your tests not following Independent principle, so one test should not affect other tests.

    Looking in the code you’ve provided I can assume that the problem that
    TdsTransformer.SplitTdsName() cache some data. I would suggest cleanup all shared variables:

    [TestCleanup()]
    public void Cleanup()
    {
       // cleanup all shared variables     
    }
    

    Useful links:

    • Properties of Good Tests: A-TRIP
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a set of unit tests, each with a bunch of methods, each
I have a bunch of unit tests that work on a class which executes
I have written a bunch of unit tests inside VS2010 Express and tests being
I have written a bunch of entities. I am trying to test them now.
I'm working on a Spring MVC project, and I have unit tests for all
I have a whole bunch of Unit tests and coded UI Tests setup in
I have a bunch of methods returning HashSet. I would like my unit test
I have a bunch of .net nunit tests that need to be run on
I have a bunch of unit tests in my visual studio project and code
I have some unit tests set up in my PowerBuilder application that run through

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.