ReSharper Recipes. File templates.

Now I’ll redeem a promise about which I’ve told in the previous article. I’ll tell you how to reduce your working hours which you spend on writing tests.

If you can create new classes with the help of alt +ins in the Solution Explorer, why don’t we create text classes with all we need at once?

It is really possible, but in a more trivial way. So, let’s start.

Again we need a draft, but now we can use it with different names and with all inclusions of «using ». So, let’s use this code for our experiment.

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Tests {
    [TestClass]
    public class Class1 {
        [TestMethod]
        public void TestMethod() {  }
    }
}

Continue reading

ReSharper: Code snippets for tests.

I’ve always felt too lazy to key in full words, write different standard formulatings, it usually drives me crazy or make me bored. Some time before it hasn’t been so ruefully, but during these two years of working with ReSharper everything redoubled, for instance I don’t type «public» at all, I prefer to type «р» and press space, so ReSharper will finish writing. The only thing that I write by myself is names of methods, classes and tests. I would like to stress that only the names and not all notes. And variables are always named by ReSharper too. =) I’m a real sluggard!

I would like to share my knowledge with you how to develop such laziness and how ReSharper helps in it. Because of we hold to Test Driven Development, all code snippets will hold to texts.

All texts begin with an add of text class.

using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
public class classname { }

Everything doesn’t change except the title of text class. I physically suffer from the look how the others write it. In information about myself I’ve told that at work we practice XP and that’s why pair programming is the imprescriptible point.

After choosing the class you need to choose the text method.

[TestClass]
public class classname {
    [TestMethod]
    public void name() {
    }
}

Look how much text there is! And there are only 2(two) comprehensible words! Typing everything isn’t the easy way, so we need to automatize it. With the help of the ReSharper it does quite fast and easy.

Continue reading