Home > Code Generation, Testing > Code Templates – Silverlight testing

Code Templates – Silverlight testing

October 29th, 2012

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: