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
Shortcut | Description |
Misc Items | |
nie | throw new NotImplementedException(); |
Rhino Mocks Items | |
mock | MockRepository.GenerateMock<T>(); |
stub | MockRepository.GenerateStub<T>(); |
mockery | MockRepository mockery = new MockRepository(); |
urm | using Rhino.Mocks; |
NUnit Items | |
a | Assert.<Assertion> |
ae | Assert.AreEqual(<expected>, <actual>); |
ai | Assert.IsInstanceOfType(typeof(<Type>), <actual>); |
aif | Assert.IsFalse(<condition>); |
ain | Assert.IsNull(<object>); |
ait | Assert.IsTrue(<condition>); |
ann | Assert.IsNotNull(<object>); |
as | Assert.AreSame(<expected>, <actual>); |
at | Assert.That(<actual>, Is.<ConstraintAndCondition>); |
eea | [ExpectedException(typeof(<Type>))] |
ig | [Ignore(<reason>)] |
sac | StringAssert.Contains(<expected>,<actual>); |
setup | Creates a setup method for NUnit decorated with a setup attribute |
sua | [SetUp] |
ta | [Test] |
tc | Creates a test method in which you can define a name for the test. Decorated with the Test attribute. |
td | Creates a tear down method decorated with the TearDown attribute |
tda | [TearDown] |
tfa | [TestFixture] |
tfp | Creates the beginning of a TestFixture by adding the attribute and marking the class as public. |
tfsu | Creates a TestFixtureSetUp method that is decorated with the TestFixtureSetup attribute |
tftd | Creates a TestFixtureTearDown method that is decorated with the TestFixtureTearDown attribute |
tftda | [TestFixtureTearDown] |
unuf | using NUnit.Framework; |
File Templates:
Template | Description |
NUnit Test Class | Creates 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. |
SparkView | Essentially a blank file that is open for you to create a view from the Spark View Engine. The file extension is .spark |
CssStyleSheet | Similar to the SparkView template except that the extension is .css. The file is empty by default. |
Leave a Reply
You must be logged in to post a comment.