Posts Tagged ‘codesnippets’

Manage Your Code Snippets With DropBox

Friday, June 25th, 2010

I regularly work on a number of different development machines and always find it annoying when I haven’t got my latest and greatest code snippet installed. That’s where DropBox is great. The free package gives you a 2gb allowance which once you install there client software creates a DropBox folder on your machine any files placed in that folder are automatically synchronized with any other machines that you use and that have DropBox installed on.

This means that if you point your CodeSnippets folder at a folder in your DropBox they will all be magically kept up to date across multiple machines.

 

I’m going to do the same with my Resharper Template as well!!

Nunit Code Snippet

Thursday, June 24th, 2010

Here is a useful code snippet that I use all the time to create an empty unit test.

To use it go to your My Code Snippets folder, go to the snippet manager in Visual Studio (Ctrl K + Ctrl B) to get the file path if you don’t know it. Create a new text file with and appropriate name and rename the extension to .snippet and cut and paste the following xml into the file and save it.

 

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <Title>
                NUnit Test
            </Title>
        </Header>
        <Snippet>
            <References>
                <Reference>
                    <Assembly>nunit.framework.dll</Assembly>
                </Reference>
            </References>
            <Declarations>
                <Literal>
                    <ID>Test_Name</ID>
                    <ToolTip>Replace with test method name</ToolTip>
                    <Default>Test_Name</Default>
                </Literal>
            </Declarations>
            <Code Language="CSharp">
            <![CDATA[]]>
            [Test]
            public void $Test_Name$()
            {
            }
            <![CDATA[]]>
            </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets> 
 
And Bob’s your uncle it should appear in your code snippet shortcuts..Ctrl K Ctrl S to access.