Last active
February 6, 2022 13:15
-
-
Save marcduiker/5ee9fd68f92ccf6614637f3dff8aea89 to your computer and use it in GitHub Desktop.
Visual Studio C# snippet for xUnit test methods (Facts) using the naming convention proposed by http://osherove.com/blog/2005/4/3/naming-standards-for-unit-tests.html. Import the snippet using the SnippetManager in VS and type `fact[tab][tab]` inside a class to insert the snippet.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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>xUnit Fact</Title> | |
<Shortcut>fact</Shortcut> | |
<Description>Code snippet for an xUnit test method (Fact) following the naming convention UnitOfWork_StateUnderTest_ExpectedBehaviour.</Description> | |
<Author>Marc Duiker</Author> | |
</Header> | |
<Snippet> | |
<Imports> | |
<Import> | |
<Namespace>Xunit</Namespace> | |
</Import> | |
</Imports> | |
<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>Fact</ID> | |
<Function>SimpleTypeName(Fact)</Function> | |
</Literal> | |
</Declarations> | |
<Code Language="csharp"><![CDATA[[$Fact$] | |
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