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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:36:47+00:00 2026-05-29T05:36:47+00:00

I created a unit test to test if a I can login to my

  • 0

I created a unit test to test if a I can login to my ASP.NET web service. The web service works fine and even the login process.

However when trying to connect to it through my test it is giving me an error:

The URL specified (‘http://www.foo.com/’) does not correspond to
a valid directory. Tests configured to run in ASP.NET in IIS require a
valid directory to exist for the URL.

I’m running my web service through visual studio, since the project is still in development.

this is my test code:

[TestMethod()]
        [HostType("ASP.NET")]
        [UrlToTest("http://www.foo.com/")]
        public void Login_Test_It_Fails_If_GUID_IS_Wrong()
        {
            //Arrange
            Service service = new Service(); 
            string pGUID = string.Empty; 
            string connectionSQL = @"XXXXXXXXXX";
            bool targetOutput = false;

            //Act
            targetOutput = service.Login(pGUID, connectionSQL);

            //Assert
            Assert.IsFalse(targetOutput);
        }

Thanks in advance.

  • 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-29T05:36:49+00:00Added an answer on May 29, 2026 at 5:36 am

    You’re doing an integration test here, as you are testing that your application can communicate with an external dependency.

    If you wanted to unit test, you might want to explore a different approach.

    1. If the web service is something you control, you can write tests for the service itself confirming its login authentication logic.

    2. For your consuming application, you can write unit tests based off of a mock of the service to ensure that your application exhibits the correct behavior when it receives a response from the service.

    On another note, passing the connection string to use into the service seems like a poor design. Why should the calling application need to have any knowledge of what database the service should be using?

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

Sidebar

Related Questions

I am trying to run integration tests against a REST web service process that
I'm trying to unit test the classes I've created but the majority of the
I have created a unit test in my c# project which builds into a
Ruby's unit testing framework executes unit tests even though nobody creates unit test object.
I am trying to create a unit test for a method that takes a
Specifically, I'm trying to create a unit test for a method which requires uses
Background: I'm testing a function within an ASP.NET 4.0 (Web Forms not MVC) and
I can't run a unit test with formset. I try to do a test:
Visual studio created a unit test project for me based on a method (right-click
Can we have a loop inside a unit test? My method returns an IEnumerable<IEnumerable>

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.