Donn Felker

Not A Subscriber?

Join thousands of people who build and refuse to get left behind. One message a week on building, using AI as an accelerator, and staying sharp in the new AI frontier.

Receive one free message a week

January 24, 2009 Donn Felker · updated July 5, 2013

My ReSharper Templates

Recently when working with some co-workers I was flying through some menus and whipping out some code at a breakneck speed and a couple asked how I was doing it so quickly. Simple – Resharper’s live templates. I’m surprised I haven’t posted these before, but for whatever reason here they are. The NUnit templates are based off of Bellware’s NUnit snippet library, but I’ve also added some of my own as well as some common Rhino Mocks templates as well.

Without any further-ado, here they are. (Download the files at the bottom of this post).

The snippets contain the following goodies:

Live Templates

ShortcutDescription
Misc Items 
niethrow new NotImplementedException();
  
Rhino Mocks Items 
mockMockRepository.GenerateMock<T>();
stubMockRepository.GenerateStub<T>();
mockeryMockRepository mockery = new MockRepository();
urmusing Rhino.Mocks;
  
NUnit Items 
aAssert.<Assertion>
aeAssert.AreEqual(<expected>, <actual>);
aiAssert.IsInstanceOfType(typeof(<Type>), <actual>);
aifAssert.IsFalse(<condition>);
ainAssert.IsNull(<object>);
aitAssert.IsTrue(<condition>);
annAssert.IsNotNull(<object>);
asAssert.AreSame(<expected>, <actual>);
atAssert.That(<actual>, Is.<ConstraintAndCondition>);
eea[ExpectedException(typeof(<Type>))]
ig[Ignore(<reason>)]
sacStringAssert.Contains(<expected>,<actual>);
setupCreates a setup method for NUnit decorated with a setup attribute
sua[SetUp]
ta[Test]
tcCreates a test method in which you can define a name for the test. Decorated with the Test attribute.
tdCreates a tear down method decorated with the TearDown attribute
tda[TearDown]
tfa[TestFixture]
tfpCreates the beginning of a TestFixture by adding the attribute and marking the class as public.
tfsuCreates a TestFixtureSetUp method that is decorated with the TestFixtureSetup attribute
tftdCreates a TestFixtureTearDown method that is decorated with the TestFixtureTearDown attribute
tftda[TestFixtureTearDown]
unufusing NUnit.Framework;

File Templates:

TemplateDescription
NUnit Test ClassCreates a boiler plate template that uses the default namespace of the project and the file name defaults to whatever you provide in the ReSharper file name dialog. The file name is a .cs file extension.
SparkViewEssentially a blank file that is open for you to create a view from the Spark View Engine. The file extension is .spark
CssStyleSheetSimilar to the SparkView template except that the extension is .css. The file is empty by default.

Download

DonnFelker_LiveTemplates.xml

DonnFelker_FileTemplates.xml