Visual studio 建立文件時自動添加備註單元測試
描述測試
要求每回添加一個類,普通類或單元測試類文件頭自動添加備註, 好比:Copyright, FileName, Author and so on.spa
普通類文件code
操做步驟:blog
1. 找出Class.cs, 存放位置:C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class。get
2. 編輯Class.cs文件, 添加上文件備註(綠色部分)。it
/*=============================================================================================== Copyright© $year$ xxx Ltd. All rights reserved. File : $safeitemname$.cs Author : xxx xxx Created : $time$ Summary : ===============================================================================================*/ using System; using System.Collections.Generic; $if$ ($targetframeworkversion$ >= 3.5)using System.Linq; $endif$using System.Text; $if$ ($targetframeworkversion$ >= 4.5)using System.Threading.Tasks; $endif$ namespace $rootnamespace$ { class $safeitemrootname$ { } }
單元測試類文件(此處用的是NUnit測試類)io
操做步驟:class
1. 找到 UnitTest.cs, 存放位置:C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ItemTemplates\CSharp\Test\1033\BasicUnitTestim
2. 編輯UnitTest.cs文件, 添加上文件備註(綠色部分), [TestFixture] and [Test]。
/*=============================================================================================== Copyright© $year$ xxx Ltd. All rights reserved. File : $safeitemname$.cs Author : xxx xxx Created : $time$ Summary : ===============================================================================================*/ using System; using NUnit.Framework; namespace $rootnamespace$ { [TestFixture] public class $safeitemname$ { [Test] public void TestMethod1() { } } }