Integrating/Using NUnit with Visual Studio 2008 Standard and ASP.NET MVC
If you're one of the fortunate that has access to Visual Studio 2008 Professional editions or above, you might be asking, "Why would you want to use NUnit with Visual Studio 2008 Standard?". The answer is, the Standard edition (as well as Express editions) don't come integrated with a unit testing framework, nor do they come with unit testing project templates for ASP.NET MVC like the Professional edition and above. Unit testing has become more popular lately, especially with the advantages it adds for ASP.NET MVC.
However, if you're like me and can't afford the more pricey editions, there are some third party unit testing frameworks you can still use. NUnit is not your only choice, but is one of the more common frameworks and is the one I use, so I'll tell you how to get it working within Visual Studio 2008 Standard (or Visual Web Developer Express) along with debugging support while running your unit tests in ASP.NET MVC projects.
Hit the jump to see how to integrate NUnit
However, if you're like me and can't afford the more pricey editions, there are some third party unit testing frameworks you can still use. NUnit is not your only choice, but is one of the more common frameworks and is the one I use, so I'll tell you how to get it working within Visual Studio 2008 Standard (or Visual Web Developer Express) along with debugging support while running your unit tests in ASP.NET MVC projects.
Hit the jump to see how to integrate NUnit
C#.NET - Initialize auto-properties in Visual Studio 2008 like 2005
If you're like me, you like to use the "prop" snippet from Visual Studio 2005. If you don't know what I'm talking about, with a C# file open in Visual Studio 2005 (or 2008), type:
However, in 2008, prop tab tab gives you the following..
This is a problem because there's no simple quick way to initialize the variable.
You can initialize it in a constructor, but what if you're using a static class? You're only other option is to use a DefaultValue attribute like so:
The problem with using the DefaultValue attribute is that, as far as I know, it requires using Reflection. So not only is it a pain to type, you also take a performance hit.
The way that 2005 handled it still works in 2008, so the easiest solution is to use the snippet from 2005 in 2008. I have created a propx snippet to handle just that. Simply unzip and put the propx.snippet file into your My Code Snippets folder (in Windows 7 this is located at C:\Users\Gordon\Documents\Visual Studio 2008\Code Snippets\Visual C#\My Code Snippets\), restart visual studio then type propx tab tab to use it.
prop then hit tab twice. In 2005, you are able to initialize the variable like so:private string _name = "default"; public string Name { get { return _name; } set { _name = value; } }
However, in 2008, prop tab tab gives you the following..
public string Name { get; set; }
This is a problem because there's no simple quick way to initialize the variable.
You can initialize it in a constructor, but what if you're using a static class? You're only other option is to use a DefaultValue attribute like so:
[DefaultValue("default")] public string Name { get; set; }
The problem with using the DefaultValue attribute is that, as far as I know, it requires using Reflection. So not only is it a pain to type, you also take a performance hit.
The way that 2005 handled it still works in 2008, so the easiest solution is to use the snippet from 2005 in 2008. I have created a propx snippet to handle just that. Simply unzip and put the propx.snippet file into your My Code Snippets folder (in Windows 7 this is located at C:\Users\Gordon\Documents\Visual Studio 2008\Code Snippets\Visual C#\My Code Snippets\), restart visual studio then type propx tab tab to use it.
How to format XML in Smultron
In my quest to find a great text/code editor for Mac OS-X, so far, I've chosen Smultron. It has a nice set of features for what I need: It supports Unicode, can display East Asian characters just fine (shame on you TextMate), has project support, syntax highlighting, auto-complete and more, and it's free. Most importantly, it also has support to configure and run shell commands, which means you can use other apps to modify the text. One thing I found missing right off the bat was the ability to format, tabify, and indent XML, so it's time to find a command to format XML and integrate it with Smultron.
Read more to find out how to format XML in Smultron
Read more to find out how to format XML in Smultron
UAC Prompt Takes Long Time To Appear
The UAC prompt takes a long time to come up on my laptop on both Windows 7 and on Vista. On my Desktop on Windows 7, it comes up pretty fast.
The issue, according to Chris Jackson at Microsoft, is that when the UAC dims the screen, it relies on the video card, and if the video card is slow to handle the dimming, then obviously you can't just get a new video card. The simple solution (in Windows 7) is to move the UAC setting down one level, such that it doesn't dim the screen. Unfortunately, I don't believe you have this kind of control in Vista.
Of course, not having the UAC dim the screen opens you up to spoofing attacks. But like anything else, hopefully your Anti-virus or Anti-spyware will catch the attack before it happens. Without the dimming, the prompt comes up instantly for me. Anti-virus/spyware isn't perfect, but there is definitely a trade-off with waiting for the prompt to come up. With dimming, it was taking a good 4 or 5 seconds for the prompt to appear, and another 4 or 5 for it to restore the screen. That's just far too long. It's a shame that the UAC prompt by default, relies so heavily on the video card (even in Vista). Fortunately, I've never come across spoofing of the UAC yet. Knock on wood. I don't want to disable the UAC prompt completely, because its saved my butt a few times, mostly from malicious ads that are on well-known, "safe" sites.
I have reported the issue to Microsoft as Windows 7 Feedback.
The issue, according to Chris Jackson at Microsoft, is that when the UAC dims the screen, it relies on the video card, and if the video card is slow to handle the dimming, then obviously you can't just get a new video card. The simple solution (in Windows 7) is to move the UAC setting down one level, such that it doesn't dim the screen. Unfortunately, I don't believe you have this kind of control in Vista.
Of course, not having the UAC dim the screen opens you up to spoofing attacks. But like anything else, hopefully your Anti-virus or Anti-spyware will catch the attack before it happens. Without the dimming, the prompt comes up instantly for me. Anti-virus/spyware isn't perfect, but there is definitely a trade-off with waiting for the prompt to come up. With dimming, it was taking a good 4 or 5 seconds for the prompt to appear, and another 4 or 5 for it to restore the screen. That's just far too long. It's a shame that the UAC prompt by default, relies so heavily on the video card (even in Vista). Fortunately, I've never come across spoofing of the UAC yet. Knock on wood. I don't want to disable the UAC prompt completely, because its saved my butt a few times, mostly from malicious ads that are on well-known, "safe" sites.
I have reported the issue to Microsoft as Windows 7 Feedback.
Windows 7 Tips
Tim Sneath on msdn.com has compiled a list of 30 Windows 7 secrets. Excellent for anyone who enjoys productivity.
The new keyboard shortcuts (and mouse gesture equivalents) for the new window management features allow you to dock windows to the sides, maximize/restore the window vertically (without changing window width), move a window to another monitor, hide all non-active windows, peek at the desktop (allowing you to see gadgets or icons without moving windows), set focus to the taskbar, or launch apps from the taskbar, all just with simple key combinations involving the Windows key.
Another useful tip is to Shift+Right-Click a folder to show the "Open Command Prompt Here" option in the context menu, which sets current working directory to that folder within the command shell.
Hit the jump to see more Windows 7 tips
The new keyboard shortcuts (and mouse gesture equivalents) for the new window management features allow you to dock windows to the sides, maximize/restore the window vertically (without changing window width), move a window to another monitor, hide all non-active windows, peek at the desktop (allowing you to see gadgets or icons without moving windows), set focus to the taskbar, or launch apps from the taskbar, all just with simple key combinations involving the Windows key.
Another useful tip is to Shift+Right-Click a folder to show the "Open Command Prompt Here" option in the context menu, which sets current working directory to that folder within the command shell.
Hit the jump to see more Windows 7 tips
alphatrak
Bringing you the coding smackdown since '95
Bringing you the coding smackdown since '95
Now Playing
- StarCraft - PC
Now Reading
- Death Note
- Ikigami: The Ultimate Limit
- Infinite Game Universe: Mathematical Techniques
- Microserfs by Douglas Coupland
- Pro Android 2