# Wednesday, March 03, 2010

We did the Chilly Hilly 2010 bike race with Elliott last Saturday, along with 6000 other riders. Lots of hills and fun.

posted on Wednesday, March 03, 2010 7:27:03 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
# Monday, February 15, 2010

We just released an update of Pex on Devlabs that adds support for Visual Studio 2010 RC (the release also contains a number of bug fixes). Read more about it on our release notes page.

posted on Monday, February 15, 2010 1:03:30 PM (Pacific Standard Time, UTC-08:00)  #    Comments [7]
# Friday, January 29, 2010

We just released a new version of Pex and Moles that brings a number of bug fixes and various improvements to the behaviors for SharePoint and Asp.NET.

Improvements

  • Interaction with the Source Control provider has been significantly improved for Moles
  • Support for Moles of nested types.
  • Improved logging in the Host Type
  • Improved Behaved collections
  • Added Behaved types for mscorlib and System.Web types.

Bug fixes

  • Updated several outdated section in the documentation
  • Updated missing classes in the SharePoint samples
  • Fixed a limitation of the profiler that would silently fail to instrument certain methods

Breaking Changes

  • We have formalized the naming convention of Moles and Stubs and found some holes along the way. Some mole method might have a new name under this version of the compiler.
posted on Friday, January 29, 2010 9:48:59 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]

We did a super-short movie with Nikolai Tillmann on how to use Moles to test code depending on DateTime.Now. Enjoy!

image

posted on Friday, January 29, 2010 3:19:31 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]

In WPF, one needs to implement the DependencyProperty pattern to make properties bindable. It usually involves a lot of boiler plate code:

  • adding a static field that names the depency property,
  • adding the instance property to the type (and make sure you follow the naming convention),
  • add validation methods and wire them in the dependency constructor

These are a number steps that need to be done again and again if you are building new WPF controls.

This is where a little transformation using CciSharp really helps with such boiler plate code. Using the DependencyAutoProperty mutator, you can define dependency properties with a single attribute. The rest is taken and validated by the compiler.

The simple scenario: Add [DependencyAutoProperty]

image

The rewritten code will contain a dependency property for the Value property, and will rewrite the value property getter and setters to use GetValue, SetValue instead.

image

Supporting default values

Default values can be specified in the DependencyProperty register method, so we want to support this as well through the DependencyAutoProperty constructor.

image

Supporting validation

Callbacks can be passed in the constructor of DependencyProperty to validate the values of the property. To support this, we use a simple naming convention: if you specify the Validate = true constructor argument, the rewritter will look for a static “Validate” + property name method whose signature is Func<T, bool>, where T is the property type. The rewritter will make sure this method is used – or raise a compilation error if it is missing.

image

An interresting point here is that the callbacks passed in the DependencyProperty.Register method are untyped (Func<object, bool>) and the user needs to make the appropriate casts himself. This is taken care of by the rewritter:

image

Have fun!

posted on Friday, January 29, 2010 9:11:50 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
# Thursday, January 28, 2010

The new version of Visual Studio 2010 supports a very cool graph viewer (powered by MSAGL) and a simple XML file format (DGML) to load your own graph. I’ve added support in QuickGraph to emit .dgml file from any graph (you will need to build the sources). For example, this snippet display a very simple graph:

image

And the result opens magically in Visual Studio 2010!

image

posted on Thursday, January 28, 2010 9:09:24 AM (Pacific Standard Time, UTC-08:00)  #    Comments [1]
# Wednesday, January 27, 2010

Je présenterai une session en francais sur l’utilisation de Pex et Moles pour tester des services SharePoint aux TechDays Paris le 8 Février de 17:30 à 18:30.

Test Unitaire de Services SharePoint avec Pex et Moles.

Durant cette session, nous montrerons comment appliquer Moles et Pex pour écrire des Test Unitaires de Services SharePoint. Moles est un outil qui permet de remplacer n'importe quelle fonction .NET par un délégué ce qui permet d'isoler le code par rapport aux objets SharePoint. De plus, à partir d'un test unitaire paramétré, Pex génère automatiquement une suite de test unitaire afin de couvrir un maximum de code. Plus d'information sur Pex et Moles sur research.microsoft.com/pex

posted on Wednesday, January 27, 2010 8:58:22 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
# Friday, January 15, 2010

We just released Pex 0.21.50115.2. This release brings bug fixes, a big renaming from “Stubs” to “Moles” and improved infrastructure to build behaved types (formerly known as beavers).

Bug Fixes

  • The Moles VsHost fails to execute unit tests in different assemblies.
  • Pex deletes the report folder it is currently writing to.
  • Support for named indexers in Stubs
  • Fixed bugs in how Pex reasons about System.Convert.ToBase64, DateTime
  • Invalid support for protected members in the stubs generation

Breaking changes

  • The Stubs framework was renamed to Moles framework. We have decided to make the Moles the center of the framework and as a consequence, renamed ‘Stubs’ to ‘Moles’. (This does not mean that we encourage writing untestable code, as Mole help to make it testable. You should still refactor your code to make it testable whenever possible, and only use Moles when that’s the only choice). The impact is that
    • Microsoft.Stubs.Framework was renamed to Microsoft.Moles.Framework
    • The moles and stubs get generated in subnamespaces ‘.Moles’ rather ‘.Stubs’.
    • See below for the list of steps to upgrade your applications.
  • BaseMembers in Moles have been deprecated: this helper is not useful as it can be acheive in a better way through a constructor. We decided to remove it to reduce code size. The second reason is that BaseMembers would only work for types inside of the same assembly, which might seem inconsistent.
  • PexGoal.Reached is replaced by PexAssert.ReachEventually(). The PexGoal class has been integrated into PexAssert through the ReachEventually method which should be used with the [PexAssertReachEventually] attribute.
  • PexChoose simplified: we’ve simplified the PexChoose API; you can now get auxiliary test inputs with a single method call: PexChoose.Value<T>(“foo”).

Migrating from previous version of Pex

Since we’ve renamed Stubs to Moles, any existing .stubx files will not work anymore.

Take a deep breath, and apply the following steps to adapt your projects:

  • change the project reference from Microsoft.Stubs.Framework.dll to Microsoft.Moles.Framework.dll
  • rename all .stubx files to .moles, and
    • rename the top <Stubs xml element to <Moles.
    • Change the XSD namespace to http://schemas.microsoft.com/moles/2010/
    • Right click on the .moles file in the Solution Explorer and change the Custom Tool Name to ‘MolesGenerator’.
    • Delete all the nested files under the .moles files
  • Remove references to any compiled .Stubs.dll files in your project
  • In general, remove all .Stubs.dll, .Stubs.xml files from your projects.
  • Rename .Stubs namespace suffixes to .Moles.
  • replace all [HostType(“Pex”)] attribute with [HostType(“Moles”)]
  • in PexAssemblyInfo.cs,
    • rename using Microsoft.Pex.Framework.Stubs to Microsoft.Pex.Framework.Moles
    • rename [assembly: PexChooseAsStubFallbackBehavior] to [assembly: PexChooseAsBehavedCurrentBehavior]
    • rename [assembly: PexChooseAsStubFallbackBehavior] to [assembly: PexChooseAsMoleCurrentBehavior]
  • In general, the ‘Fallback’ prefix has been dropped in the following methods:
    • rename FallbackAsNotImplemented() to BehaveAsNotImplemented()
    • rename class MoleFallbackBehavior to MoleBehaviors
    • rename class StubFallbackBehavior to BehavedBehavors
posted on Friday, January 15, 2010 8:14:07 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
# Tuesday, January 12, 2010

Picture-in-Picture is a very cool feature of Camtasia that allows to embed a movie stream into a screencast. It makes the screencast more lively while keeping a perfect quality of the computer screen. You've seen this kind of screencast all over the place on Channel9. Unfortunately, this feature was limited for screen recording and whiteboard session would never look that good since we had to zoom in and out to capture… not anymore.

We invested in an eBeam device that can capture the pen strokes on any whiteboard and display them on the computer. Using this device, we can do Picture-in-Picture for Whiteboard recordings! Using that device, we use the following setup: a camera on a tripod to record the person on the whiteboard, the eBeam capture software running and Camtasia recording the computer screen. The first result of this experiment is the first episode of a new show, The Verification Corner, where Rustan Leino explains Loop Invariants. The other benefit of recording the whiteboard is that you get a hard copy out it. If you go to the Channel9 page, you’ll see that you can also download a .pdf or .pptx of all the whiteboard that Rustan wrote during the session… Go check it out and tell us what you think…

image

posted on Tuesday, January 12, 2010 12:24:51 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
# Sunday, January 10, 2010

We recently acquired an eBeam system at work. This eBeam is a device that allows to record the strokes of your pens on a whiteboard or use a simple use a special pen as a mouse on a projected surface. The main application for us is to produce better RiSE Channel9 videos but there was another use that obviously cooler… projecting Craxyon Deluxe on the wall and let my 3 year old toddler take command…

posted on Sunday, January 10, 2010 9:54:26 AM (Pacific Standard Time, UTC-08:00)  #    Comments [1]