Step 3: Create a Harness
There are several approaches to creating a harness in which to run your snippet, but let's go with something very, very easy. Assume that each piece of code is its own entity. It needs to be written, handled, and tested separatelysort of like an application, huh? Precisely like an application! Build a classic dummy appa form with a single button, or a command-line app that doesn't take any parametersand add a class to it. In essence, we're giving you a sandbox where you can play without fear of breaking anything else, and make certain that you understand both what goes into and out of this function, without affecting the other code you need to upgrade.
We'll build a one-button form in C# and slap a class file into it for our drive-mapping code. It looks like this:
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace NetConnectSnippet { class DriveMappingSnippet { } }
Nothing too exciting. We'll get to deeper stuff in a moment.