How to Re-Enable Create Unit Tests Context Menu In Visual Studio 2012

To re-enable the Create Unit Tests… menu, go to Tools->Customize… to launch the Customize dialog. At the Customize dialog, go to the Commands tab, select the Context menu radio button and choose Editor Context Menus | Code Window.

You will realized that the menu item is actually available in the context menu. 🙂 The VS developers were kind enough to leave it there for us. *HeHe* Click on the Create Unit Tests… menu item and click either Move Up or Move Down. [Note: My screenshot is showing Create Unit Test in singular because I had previously tried to rename it]. Then click Close.

Restart Visual Studio 2012 and whalla! The context menu will be available!

Note: This apparently does not work in Visual Studio 2013.
Alternative is to use this Visual Studio Extension: Unit Test Generator

Get CSS/JS Intellisense In ASP.NET WebForms Using Visual Studio 2013

In Visual Studio 2013, CSS files that are included in your project/solution will now automatically be parsed and all HTML documents will gain CSS class intellisense.


ASPX and other WebForm files using the legacy editor do not benefit from this implementation in VS 2013, but may adopt the new system in future releases.

But you can still use this feature as follows:

  1. right click on the “default.aspx” file in the Solution Explorer
  2. “open with”
  3. select “HTML Editor”
  4. “ok”



Navigate To Feature In Visual Studio 2012/2013

Visual Studio’s Navigate to feature allows you to find and navigate to a specific element in your solution. Once you press the Ctrl+, combination and start typing your query*, Visual Studio will display all found elements matching your query, regardless of their type and location. To navigate to a certain element, either select it with cursor keys and press Enter or double click the element.


Emulate Visual Studio 2012’s Solution File Finder in VS.NET 2008 and 2010


“First jump up to that box using the keystroke Ctrl+/. Now type “>of ” and follow with the start of a filename. As fast as you can type, Visual Studio searches your entire solution for a file or path that starts with the characters you type and you can quickly select that file (with the keyboard using the arrow keys if you wish) and open it. If you’re working in a solution with several projects or folders, this can be a significant time saver.

For those of you unfamiliar with the Command Window, you can think of it like an Immediate Window that you use with the debugger, except that instead of controlling the debuggee, you’re controlling Visual Studio. It’s like the VS macro editor, except that everything you type takes immediate effect. To have this conveniently just a Ctrl+/, > keystroke away, especially when “>of ” (short for Open File) is such a convenient acronym to search across your entire solution is awesome.”


Why Does Visual Studio Not Resolve My CSS Class Names or JS Method Names?

“Site-Relative Paths are NOT supported by Visual Studio”. So this was the solution to why I was not getting intellisense in my css. I always use site relative paths for my css files so I needed to add this line in to get Visual Studio to find my css files:

<%--To allow Visual Studio to resolve css class names for Intellisense support, css file path references must be absolute     --%>
    <% if (false) {%>
    <link href="../css/global/app.css" rel="stylesheet" />
    <link href="../css/global/base.css" rel="stylesheet" />
    <% } %>

So now with absolute reference to the css files wrapped inside of the if(false) statement, Visual Studio will be able to find the css file which contains the intellisense information however these file references won’t render on the website since they are wrapped in an if statement that never will resolve to true.

This concept can also be applied to js files and intellisene for methods.


C# “prop” code snippet for getter/setter property auto generation

Within Visual Studio, Just type “prop” and hit tab twice and the following stub will be generated automatically generate a property.

 public int MyProperty { get; set; }

You can find the entire list of snippets here:

In Visual Studio 2005,
C:\Program Files\Microsoft Visual Studio 8\VC#\Snippets\1033\Visual C#

In Visual Studio 2008,
C:\Program Files\Microsoft Visual Studio 9.0\VC#\Snippets\1033\Visual C#

In Visual Studio 2010,
C:\Program Files\Microsoft Visual Studio 10.0\VC#\Snippets\1033\Visual C#

NUnit Setup In Visual Studio And Example NUnit test case

Once installed, Within Visual Studio, Tools | Nunitit | NUnitit settings

Change NUnit-GUI Executable to install path: C:\Program Files\NUnit 2.5.5\bin\net-2.0\nunit.exe

When you want to run an NUnit test, set the NUnit project in VS.NET as startup project and navigate to Tools | Debug Nunit GUI. The Nunit test interface will then load.

From there you can execute your test cases.

Very simple example of NUnit test:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

    public class TestJHAServiceManager
        public void GetJHANames()
            List<string> strings = JHAServiceManager.GetJHANames("jUnit");

        /// <summary>
        /// Gets the JHA details with invalid id.
        /// Another example where an exception is expected
        /// </summary>
        public void GetJHADetailsWithInvalidId()
            JobHazardAnalysis jha = new JobHazardAnalysis()
                Id = -25


Code Documenting Made Easy – GhostDOC

GhostDoc is a free Visual Studio extension that automatically generates XML documentation comments for methods and properties based on their type, parameters, name, and other contextual information.

When generating documentation for class derived from a base class or for interface implementation (e.g. .NET Framework or your custom framework), GhostDoc will use the documentation that Microsoft or the framework vendor has already written for the base class or interface.