Skip to content

Instantly share code, notes, and snippets.

@dampee
Forked from sionjlewis/UnitTestMethod.Snippet
Created February 21, 2022 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dampee/b99666c5f5f43ab3a3d1882a250618ef to your computer and use it in GitHub Desktop.
Save dampee/b99666c5f5f43ab3a3d1882a250618ef to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Unit Test Method</Title>
<Author>Siôn J. Lewis</Author>
<Description>Adds a unit test method with comments based on the AAA (Arrange,Act,Assert) pattern</Description>
<HelpUrl>https://msdn.microsoft.com/en-us/library/ms165394.aspx</HelpUrl>
<Shortcut>utest</Shortcut>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal Editable="true">
<ID>MethodName</ID>
<ToolTip>Method name: e.g. IsStrawberryRed</ToolTip>
<Default>MethodName</Default>
<Function>
</Function>
</Literal>
<Literal Editable="true">
<ID>Condition</ID>
<ToolTip>Condition: e.g. WhenRipe</ToolTip>
<Default>Condition</Default>
<Function>
</Function>
</Literal>
<Literal Editable="true">
<ID>ExpectedResult</ID>
<ToolTip>Expected result: e.g. True</ToolTip>
<Default>ExpectedResult</Default>
<Function>
</Function>
</Literal>
</Declarations>
<Code Language="CSharp" Kind="method decl"><![CDATA[[TestMethod]
public void $MethodName$_$Condition$_$ExpectedResult$()
{
// Arrange
$end$
// Act
// Assert
Assert.Fail();
}]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment