开发者

Useful Resharper Live Templates?

What are some useful liv开发者_运维百科e templates for Resharper that you use on a daily basis?


I use a whole host (>1000) of live templates for creation of general-purpose structures a la CodeRush. You can find them here


I have a custom template for creating test methods that I use all the time.

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

And also in conjunction with a custom file template for creating the test fixture.

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

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


This saves some typing for me, it creates a NUnit TestCase stub that handles exceptioncases:

[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));
}
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜