2010-06-27 27 views
0

我正在觀看使用Resharper(VS 2010或2008,不確定)的人的屏幕錄像,他們能夠用字符串文字填充測試名稱:命令將文字寫入符號(Resharper?VS2010?)

public class FooTest 
{ 
    public void "runs backgrounnd process until complete" 

,然後一些命令將其轉化爲

public class FooTest 
{ 
    public void runs_backgrounnd_process_until_complete() 
    { 

我想知道是否有人知道這是什麼命令了。

+1

我們也可以知道此屏幕錄像的網址嗎? – 2010-06-27 20:36:26

+0

我不認爲我能找到它。但是我做了http://www.iamnotmyself.com/2009/10/23/TDDKataCalculatorDemonstration.aspx。也許它有音頻?不在我的機器上。 – 2010-06-27 20:47:07

回答

0

它是一個視覺工作室宏,最初來自JP Boodhoo的Nothing But .NET Boot Camp類。這是它:

Sub ConvertLine() 
     If DTE.ActiveDocument Is Nothing Then Return 

     Dim isOpen As Boolean = OpenUndo("ConvertLine") 

     Dim selection As TextSelection = CType(DTE.ActiveDocument.Selection(), EnvDTE.TextSelection) 
     selection.SelectLine() 
     If selection.Text = "" Then Return 

     Dim classKeyword As String = "class """ 
     Dim methodKeyword As String = "void """ 
     Dim classIndex As Integer = selection.Text.IndexOf(classKeyword) 
     Dim methodIndex As Integer = selection.Text.IndexOf(methodKeyword) 
     If classIndex + methodIndex < 0 Then Return 

     Dim index = CType(IIf(classIndex >= 0, classIndex, methodIndex), Integer) 
     Dim prefix = selection.Text.Substring(0, index) + CType(IIf(classIndex >= 0, classKeyword, methodKeyword), String) 
     Dim description As String = selection.Text.Replace(prefix, String.Empty) 

     Dim conversion As String = Common.ReplaceSpacesWithUnderscores(description) 
     conversion = Common.ReplaceApostrophesWithUnderscores(conversion) 
     conversion = Common.ReplaceQuotesWithUnderscores(conversion) 

     selection.Text = prefix.Replace("""", String.Empty) + conversion 
     If prefix.Contains(methodKeyword) Then selection.LineDown() Else selection.LineUp() 
     selection.EndOfLine() 

     CloseUndo(isOpen) 
    End Sub 
+0

啊,這裏是JP的原文。 http://blog.jpboodhoo.com/MacroToAidBDDTestNamingStyle.aspx – NotMyself 2010-06-28 14:49:02

0

看起來像一個「活模板」。如果你注意到,他輸入fact,然後用測試方法的骨架代替。編輯,看起來像來自xUnit.net contrib項目。你也應該能夠爲nUnit測試用例做類似的事情。