lundi 25 février 2013

Powershell script parameters with complex default value

I needed to create a Powershell script with some parameters having a non-trivial default value and I didn't find any quick reference to do that. In here, I have a parameter having the current week number as a default value:

param
(
  [int] $week = $(Get-Date -UFormat %V)
)

MSTest ReSharper live templates

When developing in Visual studio with MSTest, I like using ReSharper live templates to quickly create my test classes and methods.

To create a test class, I map the following template to "tc":

[TestClass]
public class $TestClass$
{
    $END$
}

To create a test initialize, I map "ti" to:

[TestInitialize]
public void TestInitialize()
{
    $END$
}

And to create a test method, I use "tm" with:

[TestMethod]
public void $TestName$()
{
    $END$
}