DevExpress CodeRush Tips and Tricks http://www.skorkin.com Tips and Tricks for DevExpress IDE Tools: CodeRush, Refactor! and DXCore Thu, 24 Jan 2013 03:46:38 +0000 en-US hourly 1 https://wordpress.org/?v=5.6 Managing tests with the Unit Test Runner tool window http://www.skorkin.com/2012/10/managing-tests-with-the-unit-test-runner-tool-window/ Mon, 29 Oct 2012 18:43:23 +0000 http://www.skorkin.com/?p=6299 The Unit Test Runner tool window is designed to review, navigate, execute, and manage unit test cases of the entire solution. Here is what it looks like:

CodeRush Unit Test Runner Tool Window

The window contains the following parts:

  • A toolbar to execute test operations and change window properties;
  • A filter box to find required test cases;
  • A solution tests tree;
  • Details of tests run;
  • A status bar with a quick status info.

Toolbar

The toolbar has the following options:

Icon

Button

Description

  Run Runs a single test or several tests from the selected node in the tests tree.
  Run all Runs all test cases in the current solution.
  Debug Debugs a single test or several tests from the selected node in the tests tree.
  Repeat last test(s) Runs test cases that were previously executed or debugged.
  Stop Stops the current test run process, if any.
  Refresh tests tree Performs a tests search operation to find new tests or remove the deleted ones.
  Hide test run details Hides the details tabs of the test runs.
  Show test run details on right Sets the landscape layout for the tests tree and details of a test run.
  Show test run details below Sets the portrait layout for the tests tree and details of a test run.
  Show failed only Filters the tests tree to show only failed tests.
  Show ignored only Filters the tests tree to show only ignored tests.
  Grouping Groups the tests tree by Project, Category, Namespace, or without grouping (flat view).

Filter and Tests Tree

The filter text box allows you to find the tests by name.

The tests tree contains two columns:

  • Tests. Shows test cases with a parent project, namespace and class nodes.
  • Duration. Shows the duration of each run test run.

The tree has a right-click context menu with the following options:

CodeRush Unit Test Runner Tree Context Menu

  • Go to class (test): navigates to the corresponding item selected in the tests tree.
  • Expand All: expands all nodes of the tests tree.
  • Collapse All: collapses all nodes of the tests tree.

Test Run Details and Status Bar

The details tab of the test run displays a syntax-highlighted call stacks which makes it easier to see what led to a failure:

CodeRush Unit Test Runner Details Tab

You can click the file name to open and navigate to the file with a failed test. All colors in this tab are customizable on the Test Runner  Window option page in the Options Dialog. Additional options for this tab are available in the right-click context menu:

CodeRush Unit Test Runner Details Tab Context Menu

Available options are:

Icon

Menu item

Description

 –

Copy Copies the information from the Details tab into Clipboard.
  Line View Switches the call stack view to the line view.
  Tree View Switches the call stack view to the tree view.
  Hide call stack items without file references Toggles the visibility of call stack rows depending on the file names presence to filter the call stack and make it easier to read.
  Show passed items Toggles the visibility of the passed tests.
  Show ignored items Toggles the visibility of the ignored tests.
  Show failed items Toggles the visibility of the failed tests.

 –

Zoom -> Allows you to select the zoom level of the details information.

The Console output and Console Errors tabs shows the standard output and errors of the Console correspondingly, if any.

The status bar shows a summary of total tests, passed, failed, ignored tests.

Don’t forget that you can execute the unit test operations directly from the code editor or via the dedicated unit testing shortcuts.

—–
Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: 2008 and up
Updated: Oct/29/2012
ID: C214

Similar Posts:

]]>
Code templates for generating unit testing code http://www.skorkin.com/2012/10/code-templates-for-generating-unit-testing-code/ Mon, 29 Oct 2012 18:19:29 +0000 http://www.skorkin.com/?p=6296 There are many code templates available to quickly create tests, test fixtures and assertion calls for all supported unit testing frameworks. For each test framework, they similar , so if you switched to another framework, you can use the same code templates to generate code which will be valid in a new test framework.

Common code templates are:

Template Description
tm Creates a test method.
tc/tf Creates a test fixture (class).
tsu Creates a ‘set up’ method.
ttd Creates a ‘tear down’ method.
tfsu Creates a ‘class initialize’ method.

Asserts code templates:

Template Description
ae Creates an ‘are equal’ assertion call.
an Creates an ‘is null’ assertion call.
at Creates an ‘is true’ assertion call.
af Creates an ‘is false’ assertion call.
ai Creates an ‘ignore’ assertion call.
etc…

There are also code templates for generating test attributes and using statements with the required namespace references.

Here are the code templates for various test frameworks:

—–
Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: 2008 and up
Updated: Oct/29/2012
ID: C213

Similar Posts:

]]>
Code Templates – xUnit testing http://www.skorkin.com/2012/10/code-templates-xunit-testing/ Mon, 29 Oct 2012 18:14:13 +0000 http://www.skorkin.com/?p=6292 A list of code templates specific to the xUnit unit test framework. The meaning of the text commands in bold can be seen in the corresponding topic.

Template

Expansion

tc public class «Caret»«Field(TestClsas)»«BlockAnchor»
{
 [Fact]
 public void «Field(TestMethod()
 {
            «Marker»«Target»
 }
}
tf «?Set(FixtureType,«?Paste»)»public class «Caret»«Field(FixtureTests)»«BlockAnchor» : IUseFixture<«Link(«?Get(FixtureType)»)»>
{
  private «Link(«?Get(FixtureType)»)» _Fixture;
            public void SetFixture(«Link(«?Get(FixtureType)»)» fixture)
            {
                        _Fixture = fixture;
            }
}

Or

«?Set(FixtureType,TestFixturepublic class «FieldStart»«Caret»«Link(«?Get(FixtureType)»)»«BlockAnchor»«FieldEnd» : IDisposable
{
  public «Link(«?Get(FixtureType)»)»()
  {
            «Target»
  }
 
  public void Dispose()
  {
            «FinalTarget»
  }
}
public class «Caret»«Field(FixtureTests)»«BlockAnchor» : IUseFixture<«Link(«?Get(FixtureType)»)»>
{
  private «Link(«?Get(FixtureType)»)» _Fixture;
            public void SetFixture(«Link(«?Get(FixtureType)»)» fixture)
            {
                        _Fixture = fixture;
            }
}

tm [Fact]
public void «Caret»«Field(TestMethod)»«BlockAnchor»()
{
            «Marker»«Target»
}

Asserts

Template

Expansion

ac Assert.Contains(«Caret»«Field(expected,Expected value)» «BlockAnchor», «Field(actual,Actual value)«?Semicolon»
acc Assert.Contains(«Caret»«Field(expected,Expected value)» «BlockAnchor», «Field(actual,Actual value, «Field(comparer, Comparer)«?Semicolon»
adnc/anc Assert.DoesNotContain(«Caret»«Field(expected,Expected value)»«BlockAnchor», «Field(actual,Actual value)«?Semicolon»
adncc/ancc Assert.DoesNotContain(«Caret»«Field(expected,Expected value)»«BlockAnchor», «Field(actual,Actual value, «Field(comparer, Comparer)«?Semicolon»
adntr Assert.DoesNotThrow(«Caret»«Field(value)» «BlockAnchor»)«?Semicolon»
ae Assert.Equal(«Caret»«Field(expected,Expected value)» «BlockAnchor», «Field(actual,Actual value);
ae0 Assert.Equal(0, «Caret»«?Paste»«BlockAnchor»);

Or

Assert.Equal(0, «Caret»);

ae1 Assert.Equal(1, «Caret»«?Paste»«BlockAnchor»);

Or

Assert.Equal(1, «Caret»);

aec Assert.Equal(«Caret»«Field(expected,Expected value)» «BlockAnchor», «Field(actual,Actual value, «Field(comparer, Comparer)«?Semicolon»
aem Assert.Empty(«Caret»«Field(value)»«BlockAnchor») «?Semicolon»
af Assert.False(«Caret»«Field(value)»«BlockAnchor») «?Semicolon»
aiaf Assert.IsAssignableFrom(«Caret»«Field(value)» «BlockAnchor»)«?Semicolon»
aint Assert.IsNotType(«Caret»«Field(value)»«BlockAnchor») «?Semicolon»
air Assert.InRange(«Caret»«Field(actual,The actual value to be evalua)»«BlockAnchor», «Field(low,The (inclusive) low value of the range, «Field(high,The (inclusive) high value of the range);«FinalTarget»
airc Assert.InRange(«Caret»«Field(actual,The actual value to be evalua)»«BlockAnchor», «Field(low,The (inclusive) low value of the range, «Field(high,The (inclusive) high value of the range, «Field(comparer,The comparer used to evaluate the value’s range);«FinalTarget»
ait Assert.IsType(«Caret»«Field(value)»«BlockAnchor») «?Semicolon»
an Assert.Null(«Caret»«Field(value)»«BlockAnchor») «?Semicolon»
ane Assert.NotEqual(«Caret»«Field(expected,Expected value)» «BlockAnchor», «Field(actual,Actual value);
anec Assert.NotEqual(«Caret»«Field(expected,Expected value)» «BlockAnchor», «Field(actual,Actual value, «Field(comparer, Comparer)«?Semicolon»
anem Assert.NotEmpty(«Caret»«Field(value)»«BlockAnchor»)«?Semicolon»
anir Assert.NotInRange(«Caret»«Field(actual,The actual value to be evalua)»«BlockAnchor», «Field(low,The (inclusive) low value of the range, «Field(high,The (inclusive) high value of the range);«FinalTarget»
anirc Assert.NotInRange(«Caret»«Field(actual,The actual value to be evalua)»«BlockAnchor», «Field(low,The (inclusive) low value of the range, «Field(high,The (inclusive) high value of the range, «Field(comparer,The comparer used to evaluate the value’s range);«FinalTarget»
ann Assert.NotNull(«Caret»«Field(value)»«BlockAnchor») «?Semicolon»
ans Assert.NotSame(«Caret»«Field(expected,Expected value)» «BlockAnchor», «Field(actual,Actual value)«?Semicolon»
as Assert.Same(«Caret»«Field(expected,Expected value)» «BlockAnchor», «Field(actual,Actual value)«?Semicolon»
at Assert.True(«Caret»«Field(value)»«BlockAnchor») «?Semicolon»
atr Assert.Throws(«Caret»«Field(value)»«BlockAnchor») «?Semicolon»

Attributes

Template

Expansion

[ai [AssumeIdentity(«Caret»«Field(Name,The role’s name)»«BlockAnchor»)]«FinalTarget»
[ar [AutoRollbackAttribute]«Caret»
[cd [ClassData(«Caret»«Field(Type,The class that provides the data)»«BlockAnchor»)]«FinalTarget»
[ed [ExcelData(«Caret»«Field(FileName,The filename of the XLS spreadsheet file.)»«BlockAnchor», «Field(SelectStatement,The SELECT statement that returns the data for the theory)]«FinalTarget»
[f [Fact]«Caret»
[fc [FreezeClock(«Caret»«Field(year,The frozen year)»«BlockAnchor», «Field(month,The frozen month, «Field(day,The frozen day)]«FinalTarget»
[id [InlineData(«Caret»«Field(DataValues,The data values to pass to the theory)»«BlockAnchor»)]«FinalTarget»
[odd [OleDbData(«Caret»«Field(connectionString,The OLEDB connection string to the data)»«BlockAnchor», «Field(selectStatement,The SELECT statement used to return the data for the theory)]«FinalTarget»
[pd [PropertyData(«Caret»«Field(PropertyName,The name of the public static property on the test class that will provide the test data)»«BlockAnchor»)]«FinalTarget»
[rw [RunWith(«Caret»«FieldStart(Type of command)»«Paste»«FieldEnd» «BlockAnchor»)]«FinalTarget»

Or

[RunWith(«Caret»«Field(CommandType, Type of command)»«BlockAnchor»)]«FinalTarget»

[ssd [SqlServerData(«Caret»«Field(serverName,The server name of the Microsoft SQL Server)»«BlockAnchor», «Field(databaseName,The database name, «Field(selectStatement,The SQL SELECT statement to return the data for the data theory)]«FinalTarget»
[t [Trait(«Caret»«Field(name,The trait name)»«BlockAnchor»,«Field(value,The trait value)]«FinalTarget»
[th [Theory]«Caret»
[tr [Trace]«Caret»

Namespaces

Template

Expansion

ux/uxu using Xunit;
uxe/uxue using Xunit.Extensions;
uxs/uxus using Xunit.Sdk;
—–
Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: 2008 and up
Updated: Oct/29/2012
ID: C212

Similar Posts:

]]>
Code Templates – Silverlight testing http://www.skorkin.com/2012/10/code-templates-silverlight-testing/ Mon, 29 Oct 2012 18:09:07 +0000 http://www.skorkin.com/?p=6289 A list of code templates specific to the Silverlight unit test framework. The meaning of the text commands in bold can be seen in the corresponding topic.

Template

Expansion

tc [TestClass]
public class «Caret»«Field(Tests)»«BlockAnchor»
{
            private TestContext testContextInstance;
           
            /// <summary>
            ///Gets or sets the test context which provides
            ///information about and functionality for the current test run.
            ///</summary>
            public TestContext TestContext
            {
                        get
                        {
                                    return testContextInstance;
                        }
                        set
                        {
                                    testContextInstance = value;
                        }
            }

[TestMethod]
public void «Field(Test()
{
            «Target»
}
}

tf [TestClass]
public class «Caret»«Field(Tests)»«BlockAnchor»
{
            private TestContext testContextInstance;
           
            /// <summary>
            ///Gets or sets the test context which provides
            ///information about and functionality for the current test run.
            ///</summary>
            public TestContext TestContext
            {
                        get
                        {
                                    return testContextInstance;
                        }
                        set
                        {
                                    testContextInstance = value;
                        }
            }

[TestMethod]
public void «Field(Test()
{
            «Target»
}
}

tfsu [ClassInitialize]
public void InitializeAllTests()
{
            «Caret»«Marker»
}
tftd [ClassCleanup]
public void CleanupAllTests()
{
            «Caret»«Marker»
}
tm [TestMethod]
public void «Caret»«Field(Test)»«BlockAnchor»()
{
            «Target»
}
tsu [TestInitialize]
public void Setup()
{
            «Caret»«Marker»
}
ttd [TestCleanup]
public void TearDown()
{
            «Caret»«Marker»
}

Asserts

Template

Expansion

aas/as Assert.AreSame(«Caret»«Field(expected,Expected value)» «BlockAnchor», «Field(actual,Actual value);
ae Assert.AreEqual(«Caret»«Field(expected,Expected value)» «BlockAnchor», «Field(actual,Actual value);
ae0 Assert.AreEqual(0, «Caret»«?Paste»«BlockAnchor»);

Or

Assert.AreEqual(0, «Caret»);

ae1 Assert.AreEqual(1, «Caret»«?Paste»«BlockAnchor»);

Or

Assert.AreEqual(1, «Caret»);

af Assert.IsFalse(«Caret»«Field(value)»«BlockAnchor»);
afl Assert.Fail(«Caret»«Field(value)»«BlockAnchor»);
ai Assert.Inconclusive(«Caret»«Field(value)»«BlockAnchor»);
an Assert.IsNull(«Caret»«Field(value)»«BlockAnchor»);
anae Assert.AreNotApproximatelyEqual<«Caret»«Field(TValue)» «BlockAnchor», «Field(TDifference>(«Field(unexpected,Unexpected value, «Field(actual,Actual value, «Field(delta,Difference);
ann Assert.IsNotNull(«Caret»«Field(value)»«BlockAnchor»);
ans Assert.AreNotSame(«Caret»«Field(unexpected,Unexpected value)»«BlockAnchor», «Field(actual,Actual value);
at Assert.IsTrue(«Caret»«Field(value)»«BlockAnchor»);

Attributes

Template

Expansion

[ee [ExpectedException(typeof(«Caret»NullReferenceException «BlockAnchor»))«?OneTrailing(]
[ia [Ignore«?OneTrailing(])»
[su [SetUp«?OneTrailing(])»
[t [TestMethod«?OneTrailing(])»
[tc [TestClass«?OneTrailing(])»

Or

[ClassCleanup]

[td [TestCleanup«?OneTrailing(])»
[tf [TestClass«?OneTrailing(])»
[tfsu [ClassInitialize«?OneTrailing(])»
[tftd [ClassCleanup«?OneTrailing(])»
[ti [ClassInitialize«?OneTrailing(])»
[tm [TestMethod«?OneTrailing(])»

Namespaces

Template

Expansion

umst using Microsoft.Silverlight.Testing;
umvsttut/uut using Microsoft.VisualStudio.TestTools.UnitTesting;
—–
Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: 2008 and up
Updated: Oct/29/2012
ID: C211

Similar Posts:

]]>
Code Templates – MbUnit testing http://www.skorkin.com/2012/10/code-templates-mbunit-testing/ Mon, 29 Oct 2012 18:04:32 +0000 http://www.skorkin.com/?p=6278 A list of code templates specific to the MbUnit unit test framework. The meaning of the text commands in bold can be seen in the corresponding topic.

Template Expansion
fsu [FixtureSetUp]
public void FixtureSetUp()
{
            «Caret»«Marker»
}
ftd [FixtureTearDown]
public void FixtureTearDown()
{
            «Caret»«Marker»
}
tc [TestFixture]
public class «Caret»«Field(TestFixture)»«BlockAnchor»
{
            [Test]
            public void «Field(TestMethod()
            {
                        «Marker»«FinalTarget»
            }
}
tf [TestFixture]
public class «Caret»«Field(TestFixture)»«BlockAnchor»
{
            [Test]
            public void «Field(TestMethod()
            {
                        «Marker»«FinalTarget»
            }
}
tm [Test]
public void «Caret»«Field(TestMethod)»«BlockAnchor»()
{
            «Marker»«FinalTarget»
}
tsu [SetUp]
public void SetUp()
{
            «Caret»«Marker»
}
ttd [TearDown]
public void TearDown()
{
            «Caret»«Marker»
}

Asserts

Template Expansion
aae Assert.AreApproximatelyEqual(«Caret» «Field(expectedValue,The expected value)»«BlockAnchor», «Field(actualValue, The actual value, «Field(delta,The inclusive delta between the values);«FinalTarget»
ab Assert.Between(«Caret» «Field(actualValue,The actual value)»«BlockAnchor», «Field(minimum, Inclusive minimum value, «Field(maximum,Inclusive maximum value)
abd Assert.BinaryDeserialize<«Caret» «Field(T)»«BlockAnchor»>(«Field(stream);«FinalTarget»
abs Assert.BinarySerialize(«Caret» «Field(value,The actual value)»«BlockAnchor»);«FinalTarget»
abstd Assert.BinarySerializeThenDeserialize<«Caret» «Field(T)»«BlockAnchor»>(«Field(value);«FinalTarget»
ac Assert.Contains( «Field(enumeration, The enumeration of items, «Caret»«Field(expected, The expected value expected to be found in the collection)»«BlockAnchor»)
ack Assert.ContainsKey(«Caret»«Field(dictionary,The dictionary of items)»«BlockAnchor», «Field(expectedKey, The key expected to be found in the dictionary);«FinalTarget»
ad Assert.Distinct(«Caret»«Field(values,The sequence of values to be tested)»«BlockAnchor»);«FinalTarget»
adnc/anc Assert.DoesNotContain(«Field(enumeration, The enumeration of items, «Caret»«Field(expected, The expected value expected to be found in the collection)»«BlockAnchor»)
adnck/anck Assert.DoesNotContainKey(«Caret»«Field(dictionary,The dictionary of items)»«BlockAnchor», «Field(expectedKey, The key expected to be found in the dictionary);«FinalTarget»
adnt Assert.DoesNotThrow(«Caret»«Field(value,The actual value)»«BlockAnchor»);«FinalTarget»
ae Assert.AreEqual(«Caret»«Field(expectedValue,The expected value)»«BlockAnchor», «Field(actualValue,The actual value);
aee Assert.AreElementsEqual(«Caret» «Field(expectedSequence,The expected sequence)»«BlockAnchor», «Field(actualSequence,The actual sequence);
aeeio Assert.AreElementsEqualIgnoringOrder(«Caret» «Field(expectedSequence,The expected sequence)»«BlockAnchor», «Field(actualSequence,The actual sequence);
aene Assert.AreElementsNotEqual(«Caret» «Field(expectedSequence,The expected sequence)»«BlockAnchor», «Field(actualSequence,The actual sequence);
aew Assert.EndsWith(«Caret» «Field(expectedValue,The expected value)»«BlockAnchor», «Field(actualValue,The actual value);
aex Assert.Exists(«Field(values,The sequence of values to evaluate, «Caret»«Field(predicate,The condition that must be fulfilled (returns true) by at least one element of the sequence)»«BlockAnchor»);
afa Assert.ForAll(«Field(values,The sequence of values to evaluate, «Caret»«Field(predicate,The condition that must be fulfilled (returns true) by at least one element of the sequence)»«BlockAnchor»);
afl Assert.Fail();«Caret»
afm Assert.FullMatch(«Caret» «Field(expectedValue,The expected value)»«BlockAnchor», «Field(actualValue,The actual value);
agt Assert.GreaterThan(«Caret» «Field(expectedValue,The expected value)»«BlockAnchor», «Field(actualValue,The actual value);
agtoet Assert.GtreaterThanOrEqualTo(«Caret» «Field(expectedValue,The expected value)»«BlockAnchor», «Field(actualValue,The actual value);
aiaf Assert.IsAssignableFrom(«Caret» «Field(value,The actual value)»«BlockAnchor»);«FinalTarget»
aie Assert.IsEmpty(«Caret» «Field(values,The sequence of values to be tested)»«BlockAnchor»);«FinalTarget»
aif Assert.IsFalse(«Caret» «Field(value,The actual value)»«BlockAnchor»);«FinalTarget»
aiiot Assert.IsInstanceOfType(«Caret» «Field(value,The actual value)»«BlockAnchor»);«FinalTarget»
ain Assert.IsNull(«Caret» «Field(value,The actual value)»«BlockAnchor»);«FinalTarget»
aine Assert.IsNotEmpty(«Caret» «Field(values,The sequence of values to be tested)»«BlockAnchor»);«FinalTarget»
ainiot Assert.IsNotInstanceOfType(«Caret» «Field(value,The actual value)»«BlockAnchor»);«FinalTarget»
ainn Assert.IsNotNull(«Caret» «Field(value,The actual value)»«BlockAnchor»);«FinalTarget»
aisnaf Assert.IsNotAssignableFrom(«Caret» «Field(value,The actual value)»«BlockAnchor»);«FinalTarget»
alt Assert.LessThan(«Caret» «Field(expectedValue,The expected value)»«BlockAnchor», «Field(actualValue,The actual value);
altoet Assert.GtreaterThanOrEqualTo(«Caret» «Field(expectedValue,The expected value)»«BlockAnchor», «Field(actualValue,The actual value);
anae Assert.AreNotApproximatelyEqual(«Caret» «Field(expectedValue,The expected value)»«BlockAnchor», «Field(actualValue, The actual value, «Field(delta,The inclusive delta between the values);
anb Assert.NotBetween(«Caret» «Field(actualValue,The actual value)»«BlockAnchor», «Field(minimum, Inclusive minimum value, «Field(maximum,Inclusive maximum value)
ane Assert.AreNotEqual(«Caret» «Field(expectedValue,The expected value)»«BlockAnchor», «Field(actualValue,The actual value);
ans Assert.AreNotSame(«Caret» «Field(expectedValue,The expected value)»«BlockAnchor», «Field(actualValue,The actual value);
as Assert.AreSame
axd Assert.XmlDeserialize<«Caret» «Field(T)»«BlockAnchor»>(«Field(stream);«FinalTarget»
axs Assert.BinarySerialize(«Caret» «Field(value,The actual value)»«BlockAnchor»);«FinalTarget»
axstd Assert.BinarySerializeThenDeserialize<«Caret» «Field(T)»«BlockAnchor»>(«Field(value);«FinalTarget»

Attributes

Template Expansion
[a [Annotation(«Caret» «Field(type,The annotation type)»«BlockAnchor»,«Field(message,The annotation message)«?OneTrailing(])»
[af [AssemblyFixture«?OneTrailing(])»
[ar [AssemblyResolver«Caret» «Field(assemblyResolverType,The assembly resolver type)»«BlockAnchor»«?OneTrailing(])»
[as [ApartmentState(«Caret» «Field(apartmentState,The apartment state to use)»«BlockAnchor»«?OneTrailing(])»
[au [Author(«Caret» «Field(name,The author’s name)»«BlockAnchor», «Field(email,The author’s email address, «Field(homepage,The author’s home page)«?OneTrailing(])»
[b [Bind(«Caret» «Field(path,The binding path)»«BlockAnchor»)«?OneTrailing(])»
[cj [CombinatorialJoin«?OneTrailing(])»
[co [Column(«Caret» «Field(values,The array of values in the column)»«BlockAnchor»)«?OneTrailing(])»
[con [Content«?OneTrailing(])»
[csv [CsvData«?OneTrailing(])»
[da [Data«?OneTrailing(])»
[de [Description(«Caret» «Field(description,The description to associate)»«BlockAnchor»)«?OneTrailing(])»
[do [DependsOn(«Caret» «Field(testFixtureType,The dependent test fixture type)»«BlockAnchor», «Field(testMethodName,The dependent test method name)«?OneTrailing(])»
[dop [DegreeOfParallelism(«Caret» «Field(degreeOfParallelism,The degree of parallelism)»«BlockAnchor»)«?OneTrailing(])»
[dtct [DefaultTestCaseTimeout(«Caret» «Field(timeoutSeconds,The timeout in seconds, or zero if none.)»«BlockAnchor»)«?OneTrailing(])»
[dtf [DynamicTestFactory«?OneTrailing(])»
[e [Explicit(«Caret» «Field(reason,The reason for which the test should be run explicitly)»«BlockAnchor»)«?OneTrailing(])»
[eane [ExpectedArgumentNullExeption(«Caret» «Field(message,The expected exception message)»«BlockAnchor»)«?OneTrailing(])»
[eaoore [ExpectedArgumentOutOfRangeException(«Caret» «Field(message,The expected exception message)»«BlockAnchor»)«?OneTrailing(])»
[ed [EnumData(«Caret»«Field(type,The type of the enumeration)»«BlockAnchor»)«?OneTrailing(])»
[ee [ExpectedException(«Caret» «Field(message,The expected exception message)»«BlockAnchor»)«?OneTrailing(])»
[f [Factory(«Caret» «Field(type,The declaring type of the fact)»«BlockAnchor», «Field(memberName,The factory member name)«?OneTrailing(])»
[fi [FixtureInitializer«?OneTrailing(])»
[fsu [FixtureSetUp«?OneTrailing(])»
[ftd [FixtureTearDown«?OneTrailing(])»
[h [Header(«Caret» «Field(firstColumnName,The name of the first column)»«BlockAnchor», «FinalTarget»)«?OneTrailing(])»
[i [Ignore(«Caret» «Field(reason,The reason for which the test is to be ignored)»«BlockAnchor»)«?OneTrailing(])»
[impe [Impersonate«?OneTrailing(])»
[impo [Importance(«Caret» «Field(importance,The importance to associate)»«BlockAnchor»)«?OneTrailing(])»
[j [Join«?OneTrailing(]
[md [MetaData(«Caret» «Field(metadataKey,The metadata key)»«BlockAnchor», «Field(metadataValue,metadataValue)«?OneTrailing(])»

Namespaces

Template

Expansion

umbc/umbuc/umc/umuc using MbUnit.Core;
umbf/umbuf/umf/umuf using MbUnit.Framework;
umbfcv/umbufcv/umfcv/umufcv using MbUnit.Framework.ContractVerifiers;
umbfx/umbufx/umfx/umufx using MbUnit.Framework.Xml;
—–
Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: 2008 and up
Updated: Oct/29/2012
ID: C210

Similar Posts:

]]>
Code Templates – Microsoft Visual Studio testing http://www.skorkin.com/2012/10/code-templates-microsoft-visual-studio-testing/ Mon, 29 Oct 2012 17:51:51 +0000 http://www.skorkin.com/?p=6271 A list of code templates specific to the Microsoft Visual Studio Unit Test framework. The meaning of the text commands in bold can be seen in the corresponding topic.

Template

Expansion

tc [TestClass]
public class «Caret»«Field(Tests)»«BlockAnchor»
{
            private TestContext testContextInstance;
           
            /// <summary>
            ///Gets or sets the test context which provides
            ///information about and functionality for the current test run.
            ///</summary>
            public TestContext TestContext
            {
                        get
                        {
                                    return testContextInstance;
                        }
                        set
                        {
                                    testContextInstance = value;
                        }
            }

[TestMethod]
public void «Field(Test()
{
            «Target»
}
}

tf [TestClass]
public class «Caret»«Field(Tests)»«BlockAnchor»
{
            private TestContext testContextInstance;
           
            /// <summary>
            ///Gets or sets the test context which provides
            ///information about and functionality for the current test run.
            ///</summary>
            public TestContext TestContext
            {
                        get
                        {
                                    return testContextInstance;
                        }
                        set
                        {
                                    testContextInstance = value;
                        }
            }

[TestMethod]
public void «Field(Test()
{
            «Target»
}
}

tfsu [ClassInitialize]
public void InitializeAllTests()
{
            «Caret»«Marker»
}
tftd [ClassCleanup]
public void CleanupAllTests()
{
            «Caret»«Marker»
}
tm [TestMethod]
public void «Caret»«Field(Test)»«BlockAnchor»()
{
            «Target»
}
tsu [TestInitialize]
public void Setup()
{
            «Caret»«Marker»
}
Ttd [TestCleanup]
public void TearDown()
{
            «Caret»«Marker»
}

Asserts

Template

Expansion

aas/as Assert.AreSame(«Caret»«Field(expected,Expected value)» «BlockAnchor», «Field(actual,Actual value);
ae Assert.AreEqual(«Caret»«Field(expected,Expected value)» «BlockAnchor», «Field(actual,Actual value);
ae0 Assert.AreEqual(0, «Caret»«?Paste»«BlockAnchor»);OrAssert.AreEqual(0, «Caret»);
ae1 Assert.AreEqual(1, «Caret»«?Paste»«BlockAnchor»);OrAssert.AreEqual(1, «Caret»);
af Assert.IsFalse(«Caret»«Field(value)»«BlockAnchor»);
afl Assert.Fail(«Caret»«Field(value)»«BlockAnchor»);
ai Assert.Inconclusive(«Caret»«Field(value)»«BlockAnchor»);
an Assert.IsNull(«Caret»«Field(value)»«BlockAnchor»);
anae Assert.AreNotApproximatelyEqual<«Caret» «Field(TValue)» «BlockAnchor», «Field(TDifference>(«Field(unexpected,Unexpected value, «Field(actual,Actual value, «Field(delta,Difference);
ane Assert.AreNotEqual(«Caret» «Field(expected,Expected value)» «BlockAnchor», «Field(actual,Actual value);
ann Assert.IsNotNull(«Caret»«Field(value)»«BlockAnchor»);
ans Assert.AreNotSame(«Caret»«Field(unexpected,Unexpected value)»«BlockAnchor», «Field(actual,Actual value);
at Assert.IsTrue(«Caret»«Field(value)»«BlockAnchor»);

Attributes

Template

Expansion

[ee [ExpectedException(typeof(«Caret»NullReferenceException «BlockAnchor»))«?OneTrailing(])»
[ia [Ignore«?OneTrailing(])»
[su [TestInitialize«?OneTrailing(])»
[t [TestMethod«?OneTrailing(])»
[tc [TestClass«?OneTrailing(])»Or[ClassCleanup]
[td [TestCleanup«?OneTrailing(])»
[tf [TestClass«?OneTrailing(])»
[tfsu [ClassInitialize«?OneTrailing(])»
[tftd [ClassCleanup«?OneTrailing(])»
[ti [ClassInitialize«?OneTrailing(])»
[tm [TestMethod«?OneTrailing(])»

Namespaces

Template

Expansion

umvsttut/uut using Microsoft.VisualStudio.TestTools.UnitTesting;
—–
Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: 2008 and up
Updated: Oct/29/2012
ID: C209

Similar Posts:

]]>
Support for XUnit, NUnit, MBUnit, and Visual Studio testing frameworks http://www.skorkin.com/2012/10/support-for-xunit-nunit-mbunit-and-visual-studio-testing-frameworks/ Mon, 29 Oct 2012 17:41:30 +0000 http://www.skorkin.com/?p=6269 In addition to the MSpec and Silverlight unit testing frameworks, the following test frameworks are supported by the CodeRush Unit Test Runner out of the box:

  • MbUnit, versions 2.4 and 3.2;
  • NUnit, versions 2.2, 2.4, 2.5 and higher;
  • xUnit, versions 1.5, 1.6, 1.7, 1.8 and 1.9;
  • Visual Studio built-in framework for Visual Studio 2008, 2010, 2012.

To let the Unit Test Runner find and execute test cases from the mentioned testing frameworks, you should specify the correct paths to them on the Test Runner option page if they were not resolved automatically.

Due to the extensible Test Runner architecture, you can easily add a new unit test framework support programmatically.

—–
Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: 2008 and up
Updated: Oct/29/2012
ID: C208

Similar Posts:

]]>
CodeRush Standard Templates Library http://www.skorkin.com/2012/10/coderush-standard-templates-library/ Tue, 23 Oct 2012 15:06:46 +0000 http://www.skorkin.com/?p=6262 The standard templates library contains more than one thousand static code templates designed to help you realize any coding requirements. Templates are organized by categories. For instance, there are over 25 root categories for CSharp language on the Templates option page, such as:

  • ASP.NET
  • Attributes
  • Comments
  • Declarations
  • Directives
  • Expressions
  • Graphics
  • Patterns
  • Program Blocks
  • Regions
  • Testing
  • Text
  • WCF
  • etc

Each programming language has its own set of categories and templates. You can import and export the template categories, and add your own categories with custom templates.

With the dynamic lists capability, the number of code templates can total in the tens of thousands. Having learned the template language, it is easy to remember and write code using templates very quickly.

Here are some basic code templates from the library you can start with.

Type Declarations

Type declaration templates make it easy to generate classes, structures, interfaces, enumerations, etc. They are available in the corresponding context (condition), e.g., on an empty line inside a namespace.

Mnemonic Declares
c Class
i Interface
s Struct
d Delegate
e Enumeration
a Abstract class
x Exception class

Member Declarations

Member declaration templates allow you generate new methods, properties, fields and events.

Mnemonic Declares
m Method
p Property
v Variable
ev Event

Note that the ‘v’ template may declare not only fields, but also local variables and parameters depending on the current context. In combination with the dynamic list of standard types, you can specify the desired type of a member using an additional type specification mnemonic:

Mnemonic Type
o object
b Boolean
c Char
i Int32
d Double
s string
u UInt32
etc…

Loops and blocks

Code templates for quick generation of loops such as ‘for’, ‘foreach’, ‘while’, ‘do’ and other code blocks like ‘if’, ‘switch’, ‘try/catch’ etc.

Mnemonic Loop or block
f The ‘for’ loop
fe The ‘foreach’ loop
w The ‘while’ loop
dw The ‘do/while’ loop
if The ‘if’ block
sw The ‘switch’ block
tc The ‘try/catch’ block
tcf The ‘try/catch/finally’ block
etc…

Returning values

Code templates for generating a return statement with the desired return value.

Mnemonic Return value
rn null
rt true
rf false
r0 zero
r1 one
r-1 -1
rth this
r’ single-quoted character
r” double-quoted string

Note that the ‘r’ template will execute the Smart Return feature. This feature allows you to quickly select the return value from the suggested values (e.g., local variables).

You can see the full collection of code templates for each language on the Templates option page.

—–
Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: 2008 and up
Updated: Oct/23/2012
ID: C207

Similar Posts:

]]>
CodeRush Dynamic Lists option page http://www.skorkin.com/2012/10/coderush-dynamic-lists-option-page/ Tue, 23 Oct 2012 14:58:15 +0000 http://www.skorkin.com/?p=6257 Dynamic lists are configurable on the Dynamic Lists option page. The page is language-dependent, so you can create and use language-specific dynamic lists. Here is what it looks like:

CodeRush Dynamic Lists Option Page

The option page composed of two parts:

  • The list of available dynamic lists for the selected language.
  • The list of dynamic list entries for the selected dynamic list.

Most of the available built-in dynamic lists are common for all languages. So, they are listed under the *Neutral* language.

You can add a new dynamic list by clicking the New button under the list of dynamic lists. The following dialog appears:

CodeRush Dynamic Lists Option Page New List

Dynamic list has a name (caption), variable name (identifier) and a comment (description). The ‘This list holds .NET types’ options specifies whether or not the new dynamic list contains system .NET types. If checked, the resulting types, once expanded, will be simplified by removing an extra namespace name.

Once a new dynamic list is created, you can add new dynamic list entries to it. An entry has a Key (mnemonic) and Value fields. Specify both values and click the Add button. The Replace button allows you to modify an existing entry. The Delete button removes the selected entry.

A dynamic list can also be context sensitive. Click the Show Folder Context button to specify the context for the current dynamic list. The standard context picker UI will be shown:

CodeRush Dynamic Lists Option Page Context Picker

Of course, you can modify and extend any existing dynamic lists on this option page as well.

—–
Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: 2008 and up
Updated: Oct/23/2012
ID: C206

Similar Posts:

]]>
CodeRush Dynamic templates and dynamic lists http://www.skorkin.com/2012/10/coderush-dynamic-templates-and-dynamic-lists/ http://www.skorkin.com/2012/10/coderush-dynamic-templates-and-dynamic-lists/#comments Tue, 23 Oct 2012 14:53:16 +0000 http://www.skorkin.com/?p=6250 Template dynamic lists make a single code template universal and dynamic. For instance, a template for a variable declaration can be configurable on the fly by specifying its type. In other words, a template can be expanded differently depending on the selected dynamic list. A dynamic list contains a list of possible template alternative expansions (types when used with a variable template) for a single template.

Here are some of the standard dynamic lists:

  • System .NET types (e.g., System.Boolean, System.Char, System.Int32, System.DateTime, System.Exception, System.IO.StreamReader, etc.)
  • Generic Types with one param (e.g., System.Collections.Generic.List)
  • Generic Types with two params (e.g., System.Collections.Generic.Dictionary)
  • WPF Types (e.g., System.Windows.Media.Color, System.Windows.DependencyObject)
  • etc

Each dynamic list has a caption, variable name and a comment. The variable name identifies a dynamic list and is specified for a static template to make it dynamic. When you create a dynamic template, a variable name of the dynamic list is used in combination with the static template mnemonic as follows:

TM + DLVN

where:

  • TM – Template Mnemonic
  • DLVN – Dynamic List Variable Name

Several dynamic lists may have the same variable name for identification but different captions for better dynamic list organization on the Dynamic Lists option page in the Options Dialog.

A dynamic list contains entries with Key and Value fields. A Key specifies a dynamic entry mnemonic name used in combination with the static template mnemonic. To expand a dynamic template, use the Template Mnemonic (TM) with a dynamic entry Key name. A Value is the entry value used in the template expansion. Consider the following dynamic list entries:

Key

Value

c System.Char
i System.Int32
s System.String
\ Paste the Clipboard content
/ Insert the current type name
? Insert the current method return type

Now, remember the ‘m’ template for methods. Combining the ‘m’ mnemonic with the Key dynamic list entries, we can expand the following methods:

mc – a method returning a value of the char type;
mi – a method returning a value of the integer type;
ms – a method returning a value of the string type;
m\ – a method returning a value of the type on the Clipboard;
m/ – a method returning a value of the current type;
etc.

Here, a single template ‘m’ can have as many different expansions as dynamic list entries that exist. Imagine that other templates may reuse this dynamic list and dynamic list entries are configurable and extensible. This makes the CodeRush templates collection grow dramatically reflecting the number of available code templates.

Don’t forget that you can add dynamic lists not only on the Dynamic Lists option page, but also right from the code editor window. Right-click the type declaration name or a type reference and select the Use Type In Templates… menu item:

CodeRush Use Type In Templates Context Menu

Then, specify the dynamic list entry mnemonic:

CodeRush Use Type In Templates Mnemonic Dialog

And you are done! Now, you can use this mnemonic in combination with all other existing standard and custom code templates. Custom mnemonics are added into the corresponding Custom Types dynamic list.

A great helper to remember static and dynamic template is to dock the CodeRush Training Window, which lists all available code templates in the current context.

—–
Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: 2008 and up
Updated: Oct/23/2012
ID: C205

Similar Posts:

]]>
http://www.skorkin.com/2012/10/coderush-dynamic-templates-and-dynamic-lists/feed/ 1