Skip to content

Instantly share code, notes, and snippets.

@carlpaton
Forked from osmyn/asynctest.snippet
Created August 23, 2018 21:40
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 carlpaton/77ae278b904cab2a19423809a69c2c67 to your computer and use it in GitHub Desktop.
Save carlpaton/77ae278b904cab2a19423809a69c2c67 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</Title>
<Author>Rusty Divine</Author>
<Description>Unit Test Template with 3 Parts</Description>
<HelpUrl>https://msdn.microsoft.com/en-us/library/ms165394.aspx</HelpUrl>
<SnippetTypes />
<Keywords />
<Shortcut>ut</Shortcut>
</Header>
<Snippet>
<References />
<Imports />
<Declarations>
<Literal Editable="true">
<ID>uow</ID>
<Type></Type>
<ToolTip>Name of the unit of work or scenario under test</ToolTip>
<Default>UoW</Default>
<Function></Function>
</Literal>
<Literal Editable="true">
<ID>initialcondition</ID>
<Type></Type>
<ToolTip></ToolTip>
<Default>InitialCondition</Default>
<Function></Function>
</Literal>
<Literal Editable="true">
<ID>expectedresult</ID>
<Type></Type>
<ToolTip>What your expected result is</ToolTip>
<Default>ExpectedResult</Default>
<Function></Function>
</Literal>
</Declarations>
<Code Language="csharp" Kind="method decl" Delimiter="$"><![CDATA[[TestMethod]
public void $uow$_$initialcondition$_$expectedresult$()
{
//Arrange
$end$
//Act
//Assert
}]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
@carlpaton
Copy link
Author

carlpaton commented Aug 24, 2018

Noted from Rusty:

Save this snippet in:

%USERPROFILE%\Documents\Visual Studio 2015\Code Snippets\Visual C#\My Code Snippets\

Name your snippet something like unittest.snippet.

In Visual Studio, you will then just type ut and hit tab twice to use this snippet.

If you have Resharper installed, you will either need to switch back to Visual Studio Intellisense in Resharper's options or use Ctrl+K, X to bring up the snippet menu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment