Search This Blog

Monday, August 31, 2020

Creating Unit Test Fact method code snippet in Visual Studio

Save the following xml file with the .snippet extension.

Afterwards, load it into the Code Snippet Manager in Visual Studio via 

Tools -> Code Snippet Manager -> Import

That's it. Type tt + Tab and the code block between CDATA[...] is inserted.


 <?xml version="1.0" encoding="utf-8"?>

<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">

<CodeSnippet Format="1.0.0">

<Header>

<Title>UT Fact</Title>

<Author>AYK</Author>

<Description>Add Unit Test Fact</Description>

<Shortcut>tt</Shortcut>

</Header>

<Snippet>

<Code Language="CSharp">

<![CDATA[

[Fact]

public async Task ObjectBeingTested_Action_ExpectedResult()

{

                                        //arrange

                                        //act

                                        //assert

}]]>

</Code>

</Snippet>

</CodeSnippet>

</CodeSnippets>

No comments:

Post a Comment