KellyM
KellyM

Reputation: 2532

Issues with Intellisense and class library

I am using Visual Studio 2013. I am trying to start unit testing by using this tutorial.

I have added a class library and a reference to MVC. However, the Intellisense/Autocompletion is not working properly within my class library. Currently, this is all the code I have in my test class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using System.Web.Mvc;
using System.Web;
using Application_Portal;
using Application_Portal.Controllers;

namespace ApplicationPortalTests
{
    [TestFixture]
    public class HomeControllerTest
    {
        HomeController home = new HomeController();
    }
}

The Intellisense does not seem to recognize the home variable (no suggested properties, etc.) Typing home.Index() gives the following error:

ApplicationPortalTests.HomeControllerTest.home' is a 'field' but is used like a 'type'  

Furthermore, it does not even seem to recognize "var" (as in var result = ...). Instead, when I type var and hit space, it autocompletes it as EnvironmentVariableTarget.

I have tried cleaning and rebuilding the project, and closing and reopening Visual Studio, but with no success.

What might the issue be? I appreciate any advice.

Upvotes: 1

Views: 72

Answers (1)

JuanR
JuanR

Reputation: 7803

You have declared your variable inside the class. If you want to use this variable, it must be within the context of a member. For instance:

[Test]
public void test_my_index_page()
{
     var result = home.index();
}

Upvotes: 3

Related Questions