Tuesday, February 13, 2007

NCover Setup - Part II

Following up on my previous post, I'm continuing to set up code coverage in my .NET 2.0 project with some specific criteria.

Kudos to Grant Drake (aka Kiwidude) who is very committed to the cause. I spent some time on his site last night, pouring over some of his FAQ. He left a comment on my blog earlier, citing an FAQ that I missed on his site. Plus he recommended version 1.5.4 of NCover instead of the latest 1.5.5beta. Good stuff!

So to follow through on my previous post.

The first thing I did was move my test namespace and their classes into a separate ClassLibrary. This included all the standard stuff:

  • remove the reference of NUnit from the Core library
  • add an NUnit reference to the Test library.
  • add a Core Library reference to the Test project.

After a quick compile, I dropped down to a command prompt and executed the same statement, except this time I had to specify the name of the Test harness assembly:

ncover.console nunit-console Test.dll //a Core

This worked and ...satisifies my second objective! The added bonus is now the coverage report only contains information about the Core namespace. This is great, but as an aside, since nothing has changed in the code I wonder if this is a bug in the "//a" switch? Update: The //a switch is for assemblies without their extensions, not namespaces.

As a further refinement, I can begin to take advantage of NUnit's Project capabilities. This enhancement simplifies things greatly. It allows me to:

  • test/cover multiple assemblies at a time
  • shield my build script from having any knowledge about the test harness configuration.
  • specify where to locate the configuration file (this should solve my third objective)

To create the Nunit project file:

  • open the NUnit-Gui and choose "New Project". I like to save the nunit file at the root of my solution.
  • add in the assemblies that contain your test fixtures. In my case, I have to specify the relative path to my Test Harness: /Test/bin/Debug/Test.dll

As an NUnit project file is simply an xml file, my nunit project file contains the following:

<NUnitProject>
  <Settings activeconfig="Debug" />
  <Config name="Debug" binpathtype="Auto">
	<assembly path="Test\bin\Debug\Test.dll" />
  </Config>
</NUnitProject>

With this in place, I can now generate my coverage report at the command line with the following statement:

ncover.console nunit-console TestProj.nunit //a Core

So far, this pretty good. The second objective was fairly easy, and although I've violated my first objective, Kiwidude has suggested this might be something I could correct with part of the build script, so I'll get to that soon enough.

Tomorrow, I'll tackle my third objective of being able to resolve configuration settings.

submit to reddit

Monday, February 12, 2007

NCover Setup - Part I

About a year ago, one of my projects established some best practices for test-driven development where we found our sweet spot using .NET 1.1, NUnit, NCover and NCoverBrowser. Things were going great until one day, NCover stopped producing coverage reports. Despite my best efforts, I couldn't get it working again. Panic. Frustration. Pain. Despair. Acceptance: no more coverage reports....

Now, a new project is about to take off, this one using .NET 2.0, and I'm determined to get NCover running on this project. Problem is, documentation for NCover is still no where to be found online, only mixed messages in their forums.

So, for my reference, and potentially yours, I thought I'd share how I set this up. As I'm building an application for an enterprise the requirements can get pretty complex... here's what I'm shooting for:

  1. I typically structure a project so that I have a solution folder which contains copies of all the libraries my project will require to compile. I also bundle third-party tools with the solution folder so that when a developer checks the project out of source-control, the build script has everything it needs to operate without any configuration on behalf of the developer.
  2. I want to structure the solution so that the application code and the test harness are in different assemblies.
  3. In addition to separate test and application assemblies, configuration settings from the application code must be used with the test harness.
  4. I need to drive the code coverage from a NAnt script
  5. I need to integrate the output into CruiseControl.NET

So I downloaded NCover 1.5.5 beta and cracked open a new ClassLibrary project to simulate code coverage. I wrote two classes: a simple class "Core.Class1" and a test fixture "Test.Class1Test". I compiled the solution, dropped to a command prompt and manually tried to execute ncover using relative file paths. "Unable to locate file" errors.

As soon as I put both NCover and NUnit file paths into my PATH environment variable, the error messages started to change. The following statement, executed from the "bin\Debug" folder of my project:

"ncover.console nunit-console Core.dll //a Core"
...worked!

Although adding PATH variables violates objective #1 it did produce a coverage report for the Core and Test namespaces. Since my NUnit test cases are guaranteed to be 100% covered by NUnit, I'll need to find a way to exclude the Test namespace from the report.

I'll reorganize the project into separate assemblies and see how that changes this configuration tommorrow.

Read part two: NCover Setup - Part II

submit to reddit

Friday, February 09, 2007

VB.NET Logical Operators are lame

While writing some application architecture documentation for my current project, I drew a blank looking for the technical term "short-circuit" logical operators.

These are really simple in C#.

public bool Method1()

{

   Console.WriteLine("Method1 called.");

   return false;

}

public bool Method2()

{

   Console.WriteLine("Method2 called.");

   return true;

}

public void ShowShortCircuiting()

{

   Console.WriteLine("Regular AND:");

   Console.WriteLine("Result is: {0}", Method1() & Method2());

   Console.WriteLine("Short-Circuit AND:");

   Console.WriteLine("Result is: {0}", Method1() && Method2());

}

Produces the following output:

Regular AND:
Method1 called.
Method2 called.
Result is: False
Short-Circuit AND:
Method1 called.
Result is: False

The concept is really simple too: If the first item isn't true then don't bother executing the next condition.

When speaking with a colleague, he asked if this was possible in VB.NET. Google says yes. But isn't syntax in VB is completely backward??

The C# equivalents map to VB.NET, thusly:

C#: &
VB: And
C#: &&
VB: AndAlso

To quote the article I've highlighted:

If you want the second test to be executed every time, use And. If that's not what you want, use AndAlso.

Syntax-wise, I think that this reads as: "I want this and also this to be evaluated". But if the first condition doesn't pass, (insert smirk) wouldn't it better to say, "I want this, and maybe this to be evaluated."??

I'm not sure what prompted me to switch from VB6 to C#, but boy, I'm glad I did.

Friday, February 02, 2007

Eating dog food I preach

There's a fairly large disconnect between what I personally use and what my industry has highlighted as holy-grail great. So I finally got around to creating a del.icio.us account, and managed to find the time to add it to my blog. (I found a great resource for a list of online-del.icio.us tools here)

While I'm not convinced I need the social-networking aspect, an online bookmark solution makes sense for a few reasons:

Too many browsers. I use FireFox for my day-to-day, but occasionally I'll encounter some weird bugginess in FireFox 2.0 so I'll boot up IE 7. What's interesting about switching back and forth between browsers is that once you get settled into a session with a half-dozen tabs open, you don't want to switch back during that session. I also find that I don't bookmark most pages, I use the Browser History sidebar (CTRL+H) to relocate helpful sites. An online solution makes a lot more sense; I just have to bookmark more frequently.

Obsessive Compulsion Disorder and Format C Colon Slash Syndrome. If I kept an organized list of links from the time that I started out online it would be several reams thick. Unfortunately, I never keep a list of bookmarks for too long because I start to suspect my windows machines with performance and garbage in the registry after the install is over a year old. (I start to get anxi around the six-month mark...) I tend to give into this paranoia and format my drives somewhat frequently and in doing so I always forget to backup my bookmarks.

Blog-worthy, maybe. I started my blog to capture thoughts and findings on the web, but some days, posting a blog entry is a challenge. While I do use my blog to capture URLs for reference, not all URLs are blog worthy.

...and heck, if a colleague wanted to find a URL that I found useful, I could point them to my del.icio.us account. So, maybe I do want the social aspect after all. Hmm.

Well, let's see how this experiment plays out -- I've added the delicious tag cloud to my blog on the right. If it's not there in a few months, maybe I stopped using it.

Monday, January 29, 2007

the Church of Home Depot

I once heard that Home Depot does more business with Canada than the United States does with France. I'd believe it too, I go to Home Depot on the weekends so frequently, I call it Church.

Saturday, January 27, 2007

Trusted computing

Great animated short that stabs at Trusted Computing. From the short:

In a trusted computing environment the major goal is to protect us from potential threats. The original trusted computing idea is designed to let you decide what to consider as threat and what to consider as trust worthy. You can control by your own personal conviction. The industry's interpretation of the trusted computing idea looks quite similar, aiming at the same to fight threats and to make computing trustworthier. The main difference is that you cannot decide by your own what is trustworthy and what is not because they already decided for you... and they already decided not to trust you.

Friday, January 26, 2007

Can't Touch This - Touch Screen

I was really quite impressed with the iPhone's multi-touch technology as demonstrated in the MacWorld keynote, but this puts the iPhone to shame. This article on Fast Company might have you thinking that you accidentally woke up in the year 2054. Even better, check out this video demonstration. Update: This based on some amazing work that Jeff Han of NYU has produced. Multi-touch is probably a better name than Frustrated Total Internal Reflection.

Thursday, January 18, 2007

Wired 14.08: Be an Expert on Anything

Wired magazine did a how-to issue back in august where Stephen Colbert had the cover: how to be an expert on anything. My favourite: Don't be afraid to make things up. Never fear being exposed as a fraud. Experts make things up all the time. They're qualified to.

Friday, January 12, 2007

Internet Explorer 7: Quick Reference Sheet

I've always loved that FireFox has CTRL+K for a shorcut to the search window. Turns out it's CTRL+E: Internet Explorer 7: Quick Reference Sheet Here's a shortcut key listing for Firefox which conveniently lists Internet Explorer and Opera against FireFox, though I think it might be for IE6.

Monday, January 08, 2007

Updated Template

Along with Blogger's version upgrades are some new templates. Enjoy the new look. I chose this template because the width of the posts expands with the browser window. Maybe now I'll consider posting code examples :D

Sunday, January 07, 2007

VS.NET Blogging help

Stumbled across this great post over at Stephen Chu's blog, which points to an open source Visual Studio Add-in. The Add-in allows you to copy any code snippet into the clipboard as properly formatted HTML. A great tool for blogging!

Thursday, December 21, 2006

Props to Blogger

Blogspot has finally rolled out their new version. Good job. Better administration, tagging, faster publishing. Only suggestion: spellcheck. I've upgraded my template to take advantage of these new features, and I've even tagged most of my posts. I'll update Cameron's blog soon. I've been posting more to my blog internal to our company, but hopefully this new year I'll find the time to blog more. More pictures too. If you find yourself reading this, leave comments -- they're encouraging and a good prod in the butt to write more. Incidentally, I've got lots of posts I've started but haven't finished. I should get those out, shake off the dust and post 'em.... even if they are several years old.

Software and the Metropolis

Update: the link has changed to: http://msdn.microsoft.com/en-us/library/aa480026.aspx I attended the VS Live conference back in 2004, where Pat Helland gave this really interesting talk about how IT and Software are experiencing the same trends as the evolution of major cities. The parallels are really interesting. According to Pat, we're in 1880 I've referred to this talk many times, so I'm posting a link to it now. I can't believe that was over two years ago. One of the interesting anticdotes made is that after the railroads were invented (the internet), we needed a way to package our stuff up and send it between places. Hence, the invention of cardboard in 1880. XML is Cardboard. Ever buy a memory stick from dell? The cardboard it shipped in probably weighed more than the RAM stick. The cardboard had your name on it, where it came from, a shipping number, a customs tag on it, etc, etc -- but in the end, the contents of the package were more important than the package.

Monday, December 18, 2006

Geeking with Greg: Talk on eBay architecture

Cool post on e-bay architecture. Vertical scalability is where it's at. Interesting that XSLT and local file storage are used.

Wednesday, December 13, 2006

Rogers Digital Cable

I guess the picture's okay, but I can't get over how cluegy their guide is. Half the screen is taken up by their logo, the picture in picture looks like a stretched gif and the responsiveness of the menu is sloooooow. Thankfully, with my media center, I don't have to worry about that. I download the guide settings off the internet and then use the ever-so-user-friendly user-interface of media center to browse the guide. I can scroll through the channels (all of them) in under 15 seconds, plus I can remove channels from the listings that I don't want to see. Now, the big bonus is that I can multiple receivers (finally) hooked up to the media center so I can record one show while watching another live program.

Tuesday, December 12, 2006

About Friggin Time

Since February, the Internet connection at home has been flakey.  There had also been a lot of static on the phone line, maybe from a recent snow storm, so I figured this could be interrupting the DSL service. I called Bell to come out and take a look at the phone lines. They claimed they dispatched someone, but I never heard from them.

For a short while, the Internet seemed better and the phone line service wasn't so static-y. But sure enough, the Internet got worse and the static returned. So I called Bell. I asked why they never came by the house; they claimed they had a service technician splice the phone lines. This time, they dispatched someone. They tested the outside phone lines and determined everything was great. They tested the line going into the house and determined there was something wrong.

Aha, admist all the confusion of our new son being born, I had forgotten that we had activated our alarm system. Surely, it must be the alarm system that was interfering.

So I called ADT and asked. It took them a while to get me to a technician (they don't have anybody who can answer these questions on the phone outside of 9-5 PM Monday-Friday).

So I called Bell. Bell ran some diagnostics from their helpdesk and determined that it sounded like an "unfiltered telephonic device". Is it my alarm system? Maybe. Or, it's the new 3-in-1 handset cordless phone. Apparently, they draw a lot of current on the phone line.

So, Bell recommended:

  1. Disconnect the alarm.
  2. Disconnect the phone.
  3. Good luck.

So I decided to disconnected the cordless phone, and well... nothing happened. For about one week, the Internet worked great. After that, well. It was like 14 baud. Not 56,000 baud or even 14,000 baud. 14. Bruuuuutal.

So by about May, I was able to finally get someone from ADT to come by the house. Thankfully, those bastards charged me $150 bucks to install a phone-line adapter which they should have done during the install. (Thanks F#@#ers!!) Surely now, this would resolve the unfiltered-telephonic device.

Unfortunately, no. However, between June and July, every so often, the Internet would work for a few minutes at a time. In September I was able to use a bit-torrent client for about a week before I went back to 14 baud.

So November rolls around and I've had it. Time to get off DSL and onto Cable. Make the switch from dreaded Monopoly Bell to dreaded Monopoly Rogers. We hum and haa about switching, but eventually decide to switch everything: cell, TV, Internet, home phone. We feel glad we've made the purchase, and the installer is coming the following week. Great!

For the next week, every single day Rogers calls and leaves an automated message reminding me to be there for the 8-11 am install. Every frikking day.

Sure enough, at 10:50 the installer arrives. He's bright, cheerful. The first set back is that he can't get into the cable box, so he used a sledge-hammer to annihilate the existing box. He plugs holes and installs new metal clips to hold down the cables. Fantastic.

When it comes time to hook things up inside, it took me a while to convince him that I know where I want everything installed:

"Everything's in the basement.", I say.

"How about on the main floor?", he asks.

My main floor is devoid of technology.  "You see any TVs?"

Somehow the fact that there aren't any computers, phones or TVs on the main floor doesn't phase him.  Puzzled he asks, "So... main floor?"

This guy has been great so far, so I politely assert, "Why not put it in the basement with the TV, Wireless router and phone jacks?"

Obviously, he's either not listening to me or has a fear of finished basements. "We could just move stuff on this shelf and put it next to this phone. Most people do."

I walk over to the basement.  "Okay, so how about the basement then?"

Eventually, several hours later -- everything's hooked up. The installer makes some comment like, "it's not going to work right away. You know some people freak out because it doesn't work right away." I somehow let that slide. I wonder why people would think this?  Maybe because your automated voice-messaging system has been harassing people about the install??

Just as he's leaving, he mentions that there's a provisioning problem and it should be cleared up in a few hours. Not sure what he meant by this, I call Rogers about an hour later and ask for them some clarification. We sit on hold for nearly 30 minutes before the tech suggests that he can call me back when he knows. Gee, why didn't you offer that suggestion seconds after me calling you?? So the voicemail says, "there's a problem with getting the home phone number from Bell. Everything's backed up. We don't know how long. Maybe 24 hours."

So 24 hours later, I'm on the phone again. I'm put on hold for a very long time before someone comes back and tells me that "24-48 hours."

So 72 hours after the install, I get the impression that I'm working for Rogers now. I call in, yell at their stupid automated-voice system. The story I get is "... The work-order is showing as pending. So until we get the home-phone installed, we can't activate the TV or the Internet." This blows me away. Technically, the Internet and TV are hooked up correctly, and should work. But, because the paper work says the home-phone hasn't been hooked up -- technically, nothing can be activated.  So the best they can do, is schedule someone to come out to my house and finish the install in another week. But, he can make sure I get free TV for a month. Arrrgh!!

So they book the install for 5-8 a week later.  Which they show up at 5:01 for.  My wife got home from work (I was away on business) around 5:05 to find the "you weren't here note." Bastards!!

So I book the next install, now nearly three weeks since the original install. We get home at 4:58 to find two nearly identical messages on our phone: "Hello, this is Rogers installer. I want to do install. Please call me back."

Hmmm, maybe I would call you ...if you left your phone number!  So 5:01 he's knocking on the door. The entire home-phone installation takes 1 minute: snip the wire from bell. Plug the modem into the phone jack.

24 hours later. It works.

About Friggin Time.

Thursday, September 21, 2006

Running windows 2003 on a mac

Ok, maybe you can use parallels or bootcamp to install a windows OS on a intel-chip mac, but I had no idea that Windows 2003 was supported. When I saw this, I felt inspired to use the extremely crappy camera in my cell phone to take this snap.... Either the staffer who stocked the shelves of the Macintosh section at this book store is incompetent, had no Mac books, or had a sense of humour. Posted by Picasa

Sunday, July 16, 2006

VS.NET 2005 ASP.NET Web Application add-on

At work, we've shunned the VS 2003 concept of "Web Sites". Who really thinks you can build an enterprise web-application that is developed against the web-server with FrontPage Extensions?

Fritz Onion wrote an article ages ago that showed how you could treat a standard Class Library as a web application. This is the model we've been using ever since.

I've been wanting to try out the new Visual Studio 2005 Web Application Project since it was released but am just getting around to it.

There's an Update to Visual Studio 2005 you have to download first.

Haven't spent too much time on it yet, but you don't have to hack the IDE's config settings nor set up IIS.

Bitchin'.

submit to reddit

Float's Mobile Agent

I wasn't surprised recently when my laptop's hard-drive started to sound like a Suzuki motorcycle running up and down a hilly road. I'd been running it to the limit since the day I got it, constantly downloading and iterating through several hundred-thousand files. The space around the hard-drive would get so hot that I'm pretty sure that it has cooked the fleshy part of my left-palm. So when it finally died, despite the huge bummer of having to reinstall everything, I saw this as an opportunity to clean up my files and get my laptop organized.

One of the things that I've been wanting to get more out of is my Bluetooth enabled laptop and phone. I'd tried using the Sony Ericsson software that shipped with my phone but was completely unimpressed. I'd heard of this great utility flOat's Mobile Agent (FMA), but just couldn't get it to work.

So before instead of installing the Sony Ericsson software, this time I was going to put more time into FMA. Being open-source, it naturally is a little poor on setup details and documentation. However, I found a great starter document that shows how to get it up and running. In short:

  • Using the Bluetooth software, pair your Phone with the PC
  • Bring up the context-menu of the phone, choose Connect to Serial Port -- it'll add a new COM Port. You'll need to make note of the COM port it creates (ie COM4, COM5, COM6, etc)
  • Launch FMA
  • Choose Tools -> Options. Select the COM Port that was defined for your phone. (Mine was COM6)
  • OK your way out of the Options and then choose the "Phone -> Connect" option from the menu.

After about 30 seconds, FMA identifies your phone and begins to configure itself. Immediately afterwards, the FMA dashboard knows more about your phone that you do: battery, signal strength, firmware revision, call lists for incoming / outgoing and missed calls. Once you set the "Autoconnect on startup" and "Auto-reconnect (use proximity)" FMA takes care of managing the connection to your phone transparently. In addition, FMA loads itself into your phone like it was a Bluetooth accessory like a head-set or speaker phone.

Although albeit a bit buggy (it *is* OpenSource so that's to be expected) this is a great tool that changes the way you see your phone. It has the standard tools that you would expect, such as the ability to manage your phonebook, text messages, and upload/download files to and from your phone -- plus it has some additional goodies like viewing your call-lists, sending SMS messages from your PC and synchronizing with Outlook. What's more is that it provides on-screen call-display for your incoming calls: I got the onscreen popup that my wife was calling before my phone rang!

My favorite feature is the proximity detection. Mac users with iSync have had the luxury of integrated Bluetooth proximity. When I walk away from my PC, the speakers mute and it locks my workstation. When I return, the speakers un-mute. (The "unlock workstation" checkbox is currently grayed out in the Tools -> Options).

I was impressed that it goes beyond the Sony Ericsson software capabilities and lets you control every aspect of your phone remotely: silent mode, locked keys -- you can even turn off the phone.

Even further still, I was surprised to learn that the developers of FMA have thought of the inverse -- the ability to control your PC from your phone. Once FMA is initialized, it loads itself into your phone like it was a Bluetooth accessory like a head-set or speaker phone. By default, it opens a menu of applications and tools that can be launched such as WinAmp. Among this menu list is a "General Tools" which lets you turn off your monitor, lock the workstation, hibernate, and even shutdown.

Much like UltraMon, this is a utility I'll be preaching to anyone who has a Bluetooth enabled phone and PC.

Windows 98 + high speed Internet = hilarious

Tip: If you have high speed Internet and you don't have a router or other physical firewall device, you are running at serious risk. Go buy a router!! Here's a story about how a simple OS installation turned out to be a nightmare...

My wife and I took a trip out east for my Mother-in-Law's 60th birthday. Anytime she was in our province, she'd always talk about her computer with such disappointment and how I should come out to fix it someday. Well, when I learned that their machine was completely unstable on Windows ME (gawd help me) and their tech-friendly neighbour downgraded them to Windows 98 (holy crap!) -- I knew I needed to help.

So I looked into buying a copy of XP. Strangely, an upgrade is $230 and an OEM copy is $110. The catch is that you have to buy a motherboard in order to qualify for the OEM version -- no exceptions. Even if I bought a cheapo motherboard it would still work cheaper than the upgrade. Hey Microsoft -- fix your pricing, that's stupid.

So instead of purchasing a new version, I decided that my aging computer that I haven't hooked up since we moved into our house a year ago was officially retired -- I could donate that copy to my Mother-in-Law without violating any licensing agreements.

I bought a cheap 80Gb hard-drive for $50 (+ tax, grrr) on the day of my flight out and committed to installing the new Hard-Drive and OS while I was there. The installation turned out to be the most-complicated OS install I've ever performed.

I learned that there must have been some serious security improvements to XP since the first release of the OS -- I received my copy the week XP was launched so a fresh installation needs a zillion updates. I also learned that either the high-speed Internet provider out east could care less about mitigating hackers or I just didn't realize how effective my Linksys Router is.

I ended up installing the OS three times:

The first install went flawlessly -- I kept the Internet connection unplugged until it was ready to download updates. As soon as I started up Windows Update, the initial fix (the background intelligent transfer service BITS upgrade) took forever to install. About twenty minutes in, I realized that some hacker had compromised the machine and in place of the BITS upgrade, a Trojan had been installed with the same name, and the root of the hard-drive was filling up with garbage files and executables, pop-up messages were launching: this pc was now a honey-pot for hackers. In frustration, I put the installation CD back in and rebooted -- screw this!

I wised up for the second installation and took some additional security steps. I changed permissions on the hard-drive, disabled simple sharing. I thought I turned off "File and Printer Sharing" but an hour later, I was screaming politely (in front of my father-in-law) and rebooted with the installation CD.

The third installation, I needed help. I borrowed a neighbour's DLink router and magically all the hacker non-sense stopped. Before I left Nova Scotia I convinced my father-in-law that they absolutely needed to have a router.

Looking back on it -- they claimed they had serious problems with Windows ME but fewer problems with Windows 98. Though I'm not sure how to qualify "fewer" because when I was backing up data for the re-installation their machine would crash two/three times per hour. In a way it was comical because each time it crashed my not-so-computer-friendly father-in-law would ask, "What causes that?"

I explained it the best I could -- "Running Windows 98 nearly ten years ago when everyone was on dial-up was considered "safe". Now that everyone's on broadband things have changed; security has changed. Imagine a bank with security practices from the 1950's that has no bars, silent alarms or security cameras... would you bank there?"