Skip to content

Instantly share code, notes, and snippets.

@marsen
Last active April 23, 2018 03:28
Show Gist options
  • Save marsen/fdd78f5ac6c38eeac309ef0b1d097977 to your computer and use it in GitHub Desktop.
Save marsen/fdd78f5ac6c38eeac309ef0b1d097977 to your computer and use it in GitHub Desktop.
C# snippet
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>ctor</Title>
<Shortcut>ctor</Shortcut>
<Description>建構函式的程式碼片段</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal Editable="false">
<ID>classname</ID>
<ToolTip>類別名稱</ToolTip>
<Function>ClassName()</Function>
<Default>ClassNamePlaceholder</Default>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[
/// <summary>
/// Initializes a new instance of the <see cref="$classname$" /> class.
/// </summary>
public $classname$ ()
{
$end$
}]]>
</Code>
</Snippet>
</CodeSnippet>
<?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>NSubstitute.for</Title>
<Author>Marsen</Author>
<Description>
</Description>
<HelpUrl>
</HelpUrl>
<Shortcut>subf</Shortcut>
</Header>
<Snippet>
<Declarations>
<Literal Editable="true">
<ID>InterfaceName</ID>
<ToolTip>介面或類別名稱</ToolTip>
<Default>InterfaceName</Default>
<Function>
</Function>
</Literal>
</Declarations>
<Code Language="csharp" Delimiter="$">
<![CDATA[Substitute.For<$InterfaceName$>();]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
<?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>
<Author>Marsen(from Zack)</Author>
<Description>
</Description>
<HelpUrl>
</HelpUrl>
<Shortcut>fact</Shortcut>
</Header>
<Snippet>
<Declarations>
<Literal Editable="true">
<ID>Test_FunctionName</ID>
<ToolTip>測試方法名稱</ToolTip>
<Default>Test_FunctionName</Default>
<Function>
</Function>
</Literal>
<Literal Editable="true">
<ID>Test_ClassName</ID>
<ToolTip>測試的Class</ToolTip>
<Default>Test_ClassName</Default>
<Function>
</Function>
</Literal>
<Literal Editable="true">
<ID>Test_MethodName</ID>
<ToolTip>
</ToolTip>
<Default>Test_MethodName</Default>
<Function>
</Function>
</Literal>
</Declarations>
<Code Language="csharp" Delimiter="$"><![CDATA[
#region
////// Scenario:測試情境...
////// Given:假設...
////// When:當...
////// Then:那麼...
#endregion
[Fact(DisplayName = "測試情境...")]
public void $Test_FunctionName$()
{
//// Arrange
var target = new $Test_ClassName$();
var expected = 0;
var actual = 0;
//// Act
actual = target.$Test_MethodName$();
//// Assert
Assert.True(false, "This test needs an implementation");
} ]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment