Skip to content

Instantly share code, notes, and snippets.

@marcduiker
Created June 10, 2013 20:49
Show Gist options
  • Save marcduiker/5752147 to your computer and use it in GitHub Desktop.
Save marcduiker/5752147 to your computer and use it in GitHub Desktop.
Visual Studio snippet for an NUnit test method using the common naming convention by @royosherove.
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>NUnit Test Method</Title>
<Shortcut>nutest</Shortcut>
<Description>Code snippet for an NUnit test method following the naming convention UnitOfWork_StateUnderTest_ExpectedBehaviour.</Description>
<Author>Marc Duiker</Author>
</Header>
<Snippet>
<Imports>
<Import>
<Namespace>NUnit.Framework.TestAttribute</Namespace>
</Import>
</Imports>
<References>
<Reference>
<Assembly>nunit.framework.dll</Assembly>
</Reference>
</References>
<Declarations>
<Literal>
<ID>UnitOfWork</ID>
<ToolTip>Describe the unit that will be tested.</ToolTip>
<Default>UnitOfWork</Default>
</Literal>
<Literal>
<ID>StateUnderTest</ID>
<ToolTip>Describe the initial state or preconditions.</ToolTip>
<Default>StateUnderTest</Default>
</Literal>
<Literal>
<ID>ExpectedBehaviour</ID>
<ToolTip>Describe the expected behaviour or outcome.</ToolTip>
<Default>ExpectedBehaviour</Default>
</Literal>
<Literal Editable="false">
<ID>Test</ID>
<Function>SimpleTypeName(global::NUnit.Framework.TestAttribute)</Function>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[[$Test$]
public void $UnitOfWork$_$StateUnderTest$_$ExpectedBehaviour$()
{
// Arrange
$end$
// Act
// Assert
}]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment