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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:43:03+00:00 2026-06-14T04:43:03+00:00

I have following NUnit code. I am using a switch case statement inside [SetUp]

  • 0

I have following NUnit code. I am using a switch case statement inside [SetUp]

Before the test is run it is expected to insert data into database; but it is not inserting data. What need to be corrected here?

REFERENCE:

  1. https://softwareengineering.stackexchange.com/questions/173651/nunit-setup-and-teardown

CODE

     [SetUp]
    public void TestSetUp()
    {
        switch (TestContext.CurrentContext.Test.FullName)
        {
            case "GetApplicationsTest":
                GetApplicationsTestSETUPHElper();
                break;

            case "DeleteApplicationTest":
                GetApplicationsTestSETUPHElper();
                break;

        }


    }

    private void GetApplicationsTestSETUPHElper()
    {
        SqlConnection connection = new SqlConnection(connectionString);
        using (connection)
        {
            string commandText = "INSERT INTO Status_Type VALUES (889,'s2','UT s2')";
            SqlCommand command = new SqlCommand(commandText, connection);
            command.CommandType = System.Data.CommandType.Text;
            connection.Open();
            command.ExecuteNonQuery();
        }
    }

    private void DeleteApplicationTestSETUPHElper()
    {
        SqlConnection connection = new SqlConnection(connectionString);
        using (connection)
        {
            string commandText = "INSERT INTO Status_Type VALUES (890,'s3','UT s3')";
            SqlCommand command = new SqlCommand(commandText, connection);
            command.CommandType = System.Data.CommandType.Text;
            connection.Open();
            command.ExecuteNonQuery();
        }
    }

    [Test]
    public void GetApplicationsTest()
    {

        ApplicationBL application = new ApplicationBL(connectionString);
        ApplicationSearch applicationSearch = new ApplicationSearch();
        applicationSearch.ApplicationID = 1;
        //applicationSearch.ApplicationName = "Test1";
        //applicationSearch.ApplicationURL = "Test1";
        //applicationSearch.StatusCode = 1;
        Collection<Application> applications =  application.GetApplications(applicationSearch);
    }

    [Test]
    public void DeleteApplicationTest()
    {

        ApplicationBL application = new ApplicationBL(connectionString);
        ApplicationSearch applicationSearch = new ApplicationSearch();
        applicationSearch.ApplicationID = 1;
        //applicationSearch.ApplicationName = "Test1";
        //applicationSearch.ApplicationURL = "Test1";
        //applicationSearch.StatusCode = 1;
        Collection<Application> applications = application.GetApplications(applicationSearch);
    }
  • 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-14T04:43:04+00:00Added an answer on June 14, 2026 at 4:43 am
    TestContext.CurrentContext.Test.FullName
    

    is the fully-qualified name of the test, not just the function name as you have it in the code, so the fix ought to be to put the fully-qualified name of the tests in your case statements.

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

Sidebar

Related Questions

I have following code that I'm trying to test using NUnit and Rhino mocks.
I have the following code: using System; using NUnit.Framework; using Rhino.Mocks; public class A
I have a Vector class, and I was testing the following unit test (using
I have the following code that I'd like to test: public class DirectoryProcessor {
I have the following test fixture class and for reasons beyond me NUnit decides
Using NUnit 2.5.9, the following test unexpectedly fails: [TestFixture] public class FooTest { [Test]
Today I ran into the following problem with NUnit. I have a class, that
I have following nested objects. I am using @Valid for validation in my controller.
I have following code in initialization im = imread('Image02.tif'); figure(); imagesc(im); colormap(gray); [hImage hfig
With the following code (using Moq 4.0.10501.6): HomeController controller = new HomeController(); ActionResult result

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.