views:

78

answers:

1

UPDATE: SO I am getting the error whenever I have all meta tags like HostType,AspNetDevelopmentServerHost,URLToTest. So when I comment these tags I can run the test but I need to have these tags to have the connection string available for controller to connect to database. I created a basic unit test by just right clicking on the action in asp.net mvc and saying Create unit tests...I am just trying to run a basic unit test.I am getting this error -

The test adapter 'WebHostAdapter' threw an exception while running test 'IndexTest'. The web site could not be configured correctly; getting ASP.NET process information failed. Requesting 'http://localhost:55767/VSEnterpriseHelper.axd' returned an error: The remote server returned an error: (500) Internal Server Error.

This is my method -

[TestMethod()]
        [HostType("ASP.NET")]
        [AspNetDevelopmentServerHost("C:\\Users\\Administrator\\Desktop\\MyWebsite\\Websites\\Customer1\\Customer1", "/")]
        [UrlToTest("http://localhost:55767/Admin/Dashboard")]
        public void IndexTest()
        {

            DashboardController target = new DashboardController(); // TODO: Initialize to an appropriate value
            string id = string.Empty; // TODO: Initialize to an appropriate value
            ActionResult expected = null; // TODO: Initialize to an appropriate value
            ActionResult actual;
            actual = target.Index(id);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

Any ideas what would be the problem here ? I tried to google but didnt get a good solution for my problem. I am using VS2010 Ultimate and asp.net mvc 2.0.

A: 

I created a basic unit test by just right clicking on the action in asp.net mvc and saying Create unit tests..

When you do this on an ASP.NET web application project (which is what MVC uses) Visual Studio will generate a ton of crap and will try to start the web server every time you want to run a single unit test. You don't want this.

Here are two possibilities:

  1. When you start a new ASP.NET MVC project select that you want a unit test project in the default template (preferred).
  2. You already have an ASP.NET MVC project and you want to add unit tests to it. In this case simply right click on the solution and add a new project of type Test Project. Now add reference to the ASP.NET MVC project you are testing and add a new unit test (Add New Item).
Darin Dimitrov
I updated my question..is there anything else you think I need to know..
Misnomer