Skip to content

Instantly share code, notes, and snippets.

@marcduiker
Created June 10, 2013 20:51
Show Gist options
  • Save marcduiker/5752173 to your computer and use it in GitHub Desktop.
Save marcduiker/5752173 to your computer and use it in GitHub Desktop.
Visual Studio snippet for an MSTest 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>Visual Studio Test Method</Title>
<Shortcut>mstest</Shortcut>
<Description>Code snippet for a Visual Studio test method following the naming convention UnitOfWork_StateUnderTest_ExpectedBehaviour.</Description>
<Author>Marc Duiker</Author>
</Header>
<Snippet>
<Imports>
<Import>
<Namespace>Microsoft.VisualStudio.TestTools.UnitTesting</Namespace>
</Import>
</Imports>
<References>
<Reference>
<Assembly>Microsoft.VisualStudio.QualityTools.UnitTestFramework.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>TestMethod</ID>
<Function>SimpleTypeName(global::Microsoft.VisualStudio.TestTools.UnitTesting.TestMethod)</Function>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[[$TestMethod$]
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