testy C# Test Method Snippet

This is a pretty trivial snippet, but I use it quite a lot.

Save this file as testy.snippet in your [Visual Studio]\VC#\Snippets\1033\Test directory.

Then, in the code editor, type testy, TAB+TAB to expand the snippet.

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>testy</Title>
			<Shortcut>testy</Shortcut>
			<Description>Code snippet for creating an NUnit unit test in C#</Description>
			<Author>James Schubert</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal>
					<ID>summary</ID>
					<ToolTip>Summary</ToolTip>
					<Default>Summary</Default>
				</Literal>
				<Literal>
					<ID>name</ID>
					<ToolTip>Test name</ToolTip>
					<Default>TestName</Default>
				</Literal>
                <Literal>
                    <ID>description</ID>
                    <ToolTip>Test Case</ToolTip>
                    <Default>Assumption_Does_Expectation</Default>
                </Literal>
			</Declarations>
			<Code Language="csharp"><![CDATA[ ///<summary>
/// $summary$
///</summary>
[Test]
public void $name$_When_$description$()
{
	// Arrange

	// Act

	// Assert
}
$end$]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>

Related Articles