【问题标题】:Useful Resharper Live Templates?有用的 Resharper 实时模板?
【发布时间】:2010-07-27 00:24:11
【问题描述】:

您每天都在使用哪些有用的 Resharper 实时模板?

【问题讨论】:

标签: templates resharper


【解决方案1】:

我使用整个主机 (>1000) 的实时模板来创建通用结构 a la CodeRush。你可以找到他们here

【讨论】:

  • 模板链接失效
【解决方案2】:

我有一个自定义模板,用于创建我一直使用的测试方法。

[Test]
public void $TEST_NAME$() {$END$}

还可以结合自定义文件模板来创建测试夹具。

using NBehave.Spec.NUnit;
using NUnit.Framework;
using Moq;

namespace $NAMESPACE$
{
    [TestFixture]
    public class $CLASS$ : TestBase
    {
        $END$
    }
}

【讨论】:

    【解决方案3】:

    这为我节省了一些输入,它创建了一个处理异常情况的 NUnit TestCase 存根:

    [TestCase("arg1", "arg2", "expected", typeof(Exception))]
    public void $TestName$(string $arg1$ , string $arg2$, string $expected$, Type expectedExceptionType)
    {
    if(expectedExceptionType!=null)
    {
        Assert.Throws(expectedExceptionType, () =>
                                                    {
                                                        Console.Out.WriteLine("Do something to trigger exception here!");
    
                                                    });
    }
    else
    {
        Assert.That("actual", Is.EqualTo(expected));
    }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-27
      • 2015-09-21
      • 1970-01-01
      相关资源
      最近更新 更多