<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
  <channel>
    <title>Peli's Farm - Pex, Stubs, Moles, QuickGraph, MbUnit, Reflector Addins</title>
    <link>http://blog.dotnetwiki.org/</link>
    <description>Pex, Stubs, Moles, QuickGraph, MbUnit, Reflector Addins</description>
    <language>en-us</language>
    <copyright>Jonathan 'Peli' de Halleux</copyright>
    <lastBuildDate>Thu, 12 Nov 2009 19:57:20 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.2.8279.16125</generator>
    <managingEditor>jonathan.dehalleux@gmail.com</managingEditor>
    <webMaster>jonathan.dehalleux@gmail.com</webMaster>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/PelisFarm" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=aeadd5f9-1731-4bda-9e4d-699a3a181cfa</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,aeadd5f9-1731-4bda-9e4d-699a3a181cfa.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,aeadd5f9-1731-4bda-9e4d-699a3a181cfa.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=aeadd5f9-1731-4bda-9e4d-699a3a181cfa</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We just released the Pex 0.19.41110.1 just in time for TechEd session. This version
brings an <strong>updated</strong><strong>support for Visual Studio 2010 Beta2 and
.NET 4.0 and many improvements to the Moles</strong>.
</p>
        <ul>
          <li>
            <strong>Better Dev10 Beta 2 support! </strong>We’ve upgraded our support for Visual
Studio 2010 Beta 2. This includes full support for .NET 4.0 Beta 2, the Visual Studio
Unit Test HostType and the Visual Studio integration. 
<br />
Known Beta 2 issues: 1) When running Pex for the first time, the path to Visual Studio
Unit Test is not found. You need to specify the Visual Studio ‘PublicAssemblies’ path
(“c:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies”), 2)
Don’t run Pex on v2 projects, Pex will crash. 
</li>
          <li>
            <strong>Smooth generation of Stubs and Moles</strong>: when you create a stubs and
moles assembly that is not a project reference, like one of the system assemblies,
the stubs and moles code generator will automatically compile it into an assembly
and add it to the project. This dramatically increases the performance of projects
using Stubs and Moles.<br /><a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.19VisualStudio2010Beta2SupportUnitTe_C97C/image_2.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.19VisualStudio2010Beta2SupportUnitTe_C97C/image_thumb.png" width="250" height="279" /></a></li>
          <li>
            <strong>Stubs and Moles for VisualBasic.NET: </strong>the Stubs and Moles may be used
in VisualBasic.NET projects. In that case, they are embedded as a compiled assembly. 
</li>
          <li>
            <strong>Moles support for <a href="http://nunit.org" target="_blank">NUnit</a>, <a href="http://xunit.codeplex.com/" target="_blank">xUnit.Net</a> and
others:</strong> Unit tests involving Moles require the Pex profiler to work. We’ve
added a new mode to our command line runner that allows to execute your favorite unit
test framework runner under Pex. For example, the command “pex /runner=xunit.console.exe
tests.dll” will launch the xunit runner for test.dll under Pex. x64 assemblies are
still not supported.<br /><a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.19VisualStudio2010Beta2SupportUnitTe_C97C/image_4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.19VisualStudio2010Beta2SupportUnitTe_C97C/image_thumb_1.png" width="565" height="221" /></a></li>
          <li>
            <strong>Nicer Moles Syntax:</strong> we’ve added some little tweaks to the Moles API,
such as an implicit conversion operator to the moled type, that simplifies the syntax.
Here is a small example that showcases the current syntax: step 1 moles the Bank constructor,
step 2 moles the GetAccount method and returns a mole of Account, step 3 moles the
getter and setter of the Balance property.<br />
 <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.19VisualStudio2010Beta2SupportUnitTe_C97C/image_12.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.19VisualStudio2010Beta2SupportUnitTe_C97C/image_thumb_5.png" width="436" height="490" /></a></li>
          <li>
            <strong>Fluent Mole Binding: </strong>The Bind method returns the mole itself which
allows it to be used in a fluent fashion. Interface binding is specially useful when
you need to mole custom collections – just attach an array! For example, we attach
an array of integers to a the MyList type that implements IEnumerable&lt;int&gt;.<br />
 <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.19VisualStudio2010Beta2SupportUnitTe_C97C/image_10.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.19VisualStudio2010Beta2SupportUnitTe_C97C/image_thumb_4.png" width="415" height="164" /></a></li>
          <li>
            <strong>Breaking Changes in Stubs and Moles:</strong>
            <ul>
              <li>
The stubs and moles code generator tool is now ‘StubsGenerator’. You need to path
this value in the property pages of your .stubx pages. 
</li>
              <li>
No more AsStub and AsMole: the AsStub and AsMole helpers were confusing and pretty
useless so we decided to reduce the amount of generated code by removing them. 
</li>
              <li>
The naming convention for Stubs delegate fields always mangles the parameter types
of the stubbed method, i.e. Foo(int) yields to a field called FooInt32. We used to
be smart about adding parameters but we decided to make the scheme stable and symmetric
with respect to the Moles. 
</li>
              <li>
The ‘FallbackBehavior’ property has been renamed to ‘InstanceFallbackBehavior’ in
both Stubs and Moles to make it more explicit.</li>
            </ul>
          </li>
        </ul>
        <p>
As usual, we’ve also fixed a number of bugs and added features that were reported
through our <a href="http://social.msdn.microsoft.com/Forums/en/pex/threads" target="_blank"><strong>MSDN
forums</strong></a>.
</p>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=aeadd5f9-1731-4bda-9e4d-699a3a181cfa" />
      </body>
      <title>Pex 0.19.41110.1: Better Visual Studio 2010 and .NET 4.0 Beta 2 Support, Smoother Moles</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,aeadd5f9-1731-4bda-9e4d-699a3a181cfa.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/N_2sfvTpaWw/Pex019411101BetterVisualStudio2010AndNET40Beta2SupportSmootherMoles.aspx</link>
      <pubDate>Thu, 12 Nov 2009 19:57:20 GMT</pubDate>
      <description>&lt;p&gt;
We just released the Pex 0.19.41110.1 just in time for TechEd session. This version
brings an &lt;strong&gt;updated&lt;/strong&gt; &lt;strong&gt;support for Visual Studio 2010 Beta2 and
.NET 4.0 and many improvements to the Moles&lt;/strong&gt;.
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Better Dev10 Beta 2 support! &lt;/strong&gt;We’ve upgraded our support for Visual
Studio 2010 Beta 2. This includes full support for .NET 4.0 Beta 2, the Visual Studio
Unit Test HostType and the Visual Studio integration. 
&lt;br&gt;
Known Beta 2 issues: 1) When running Pex for the first time, the path to Visual Studio
Unit Test is not found. You need to specify the Visual Studio ‘PublicAssemblies’ path
(“c:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies”), 2)
Don’t run Pex on v2 projects, Pex will crash. 
&lt;li&gt;
&lt;strong&gt;Smooth generation of Stubs and Moles&lt;/strong&gt;: when you create a stubs and
moles assembly that is not a project reference, like one of the system assemblies,
the stubs and moles code generator will automatically compile it into an assembly
and add it to the project. This dramatically increases the performance of projects
using Stubs and Moles.&lt;br&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.19VisualStudio2010Beta2SupportUnitTe_C97C/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.19VisualStudio2010Beta2SupportUnitTe_C97C/image_thumb.png" width="250" height="279"&gt;&lt;/a&gt; 
&lt;li&gt;
&lt;strong&gt;Stubs and Moles for VisualBasic.NET: &lt;/strong&gt;the Stubs and Moles may be used
in VisualBasic.NET projects. In that case, they are embedded as a compiled assembly. 
&lt;li&gt;
&lt;strong&gt;Moles support for &lt;a href="http://nunit.org" target="_blank"&gt;NUnit&lt;/a&gt;, &lt;a href="http://xunit.codeplex.com/" target="_blank"&gt;xUnit.Net&lt;/a&gt; and
others:&lt;/strong&gt; Unit tests involving Moles require the Pex profiler to work. We’ve
added a new mode to our command line runner that allows to execute your favorite unit
test framework runner under Pex. For example, the command “pex /runner=xunit.console.exe
tests.dll” will launch the xunit runner for test.dll under Pex. x64 assemblies are
still not supported.&lt;br&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.19VisualStudio2010Beta2SupportUnitTe_C97C/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.19VisualStudio2010Beta2SupportUnitTe_C97C/image_thumb_1.png" width="565" height="221"&gt;&lt;/a&gt; 
&lt;li&gt;
&lt;strong&gt;Nicer Moles Syntax:&lt;/strong&gt; we’ve added some little tweaks to the Moles API,
such as an implicit conversion operator to the moled type, that simplifies the syntax.
Here is a small example that showcases the current syntax: step 1 moles the Bank constructor,
step 2 moles the GetAccount method and returns a mole of Account, step 3 moles the
getter and setter of the Balance property.&lt;br&gt;
&amp;nbsp;&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.19VisualStudio2010Beta2SupportUnitTe_C97C/image_12.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.19VisualStudio2010Beta2SupportUnitTe_C97C/image_thumb_5.png" width="436" height="490"&gt;&lt;/a&gt; 
&lt;li&gt;
&lt;strong&gt;Fluent Mole Binding: &lt;/strong&gt;The Bind method returns the mole itself which
allows it to be used in a fluent fashion. Interface binding is specially useful when
you need to mole custom collections – just attach an array! For example, we attach
an array of integers to a the MyList type that implements IEnumerable&amp;lt;int&amp;gt;.&lt;br&gt;
&amp;nbsp;&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.19VisualStudio2010Beta2SupportUnitTe_C97C/image_10.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.19VisualStudio2010Beta2SupportUnitTe_C97C/image_thumb_4.png" width="415" height="164"&gt;&lt;/a&gt; 
&lt;li&gt;
&lt;strong&gt;Breaking Changes in Stubs and Moles:&lt;/strong&gt; 
&lt;ul&gt;
&lt;li&gt;
The stubs and moles code generator tool is now ‘StubsGenerator’. You need to path
this value in the property pages of your .stubx pages. 
&lt;li&gt;
No more AsStub and AsMole: the AsStub and AsMole helpers were confusing and pretty
useless so we decided to reduce the amount of generated code by removing them. 
&lt;li&gt;
The naming convention for Stubs delegate fields always mangles the parameter types
of the stubbed method, i.e. Foo(int) yields to a field called FooInt32. We used to
be smart about adding parameters but we decided to make the scheme stable and symmetric
with respect to the Moles. 
&lt;li&gt;
The ‘FallbackBehavior’ property has been renamed to ‘InstanceFallbackBehavior’ in
both Stubs and Moles to make it more explicit.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
As usual, we’ve also fixed a number of bugs and added features that were reported
through our &lt;a href="http://social.msdn.microsoft.com/Forums/en/pex/threads" target="_blank"&gt;&lt;strong&gt;MSDN
forums&lt;/strong&gt;&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=aeadd5f9-1731-4bda-9e4d-699a3a181cfa" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,aeadd5f9-1731-4bda-9e4d-699a3a181cfa.aspx</comments>
      <category>Moles</category>
      <category>Pex</category>
      <category>Stubs</category>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/11/12/Pex019411101BetterVisualStudio2010AndNET40Beta2SupportSmootherMoles.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=1fadab4f-ee5c-4954-b70c-8b6c317ff586</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,1fadab4f-ee5c-4954-b70c-8b6c317ff586.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,1fadab4f-ee5c-4954-b70c-8b6c317ff586.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=1fadab4f-ee5c-4954-b70c-8b6c317ff586</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’ll be presenting <a href="http://www.visug.be/Eventdetails/tabid/95/EventId/18/Default.aspx">Stubs
and Moles</a> at the Visual Studio User Group on <strong>November 3rd</strong>. See
you there…
</p>
        <blockquote>
          <p>
Stubs is a lightweight framework for test stubs and detours in .NET that is entirely
based on delegates, type safe, Refactorable, debuggable and source code generated. 
<br />
Stubs also allows to replace  any .NET method with a user-defined delegate, including
non-virtual/static methods in sealed types. Stubs is fully integrated into Pex , an
automated white box test generation tool for .NET. 
<br /><a href="http://research.microsoft.com/en-us/projects/stubs/">http://research.microsoft.com/en-us/projects/stubs/</a></p>
        </blockquote>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=1fadab4f-ee5c-4954-b70c-8b6c317ff586" />
      </body>
      <title>Nov 3rd: Stubs and Moles talk at VISUG</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,1fadab4f-ee5c-4954-b70c-8b6c317ff586.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/bjjdeShDSNo/Nov3rdStubsAndMolesTalkAtVISUG.aspx</link>
      <pubDate>Sun, 25 Oct 2009 09:45:44 GMT</pubDate>
      <description>&lt;p&gt;
I’ll be presenting &lt;a href="http://www.visug.be/Eventdetails/tabid/95/EventId/18/Default.aspx"&gt;Stubs
and Moles&lt;/a&gt; at the Visual Studio User Group on &lt;strong&gt;November 3rd&lt;/strong&gt;. See
you there…
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
Stubs is a lightweight framework for test stubs and detours in .NET that is entirely
based on delegates, type safe, Refactorable, debuggable and source code generated. 
&lt;br&gt;
Stubs also allows to replace&amp;nbsp; any .NET method with a user-defined delegate, including
non-virtual/static methods in sealed types. Stubs is fully integrated into Pex , an
automated white box test generation tool for .NET. 
&lt;br&gt;
&lt;a href="http://research.microsoft.com/en-us/projects/stubs/"&gt;http://research.microsoft.com/en-us/projects/stubs/&lt;/a&gt;
&lt;/p&gt;
&lt;/blockquote&gt;&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=1fadab4f-ee5c-4954-b70c-8b6c317ff586" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,1fadab4f-ee5c-4954-b70c-8b6c317ff586.aspx</comments>
      <category>Moles</category>
      <category>Pex</category>
      <category>Stubs</category>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/10/25/Nov3rdStubsAndMolesTalkAtVISUG.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=176eec91-8426-4d06-8c68-46b9ad09c2ff</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,176eec91-8426-4d06-8c68-46b9ad09c2ff.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,176eec91-8426-4d06-8c68-46b9ad09c2ff.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=176eec91-8426-4d06-8c68-46b9ad09c2ff</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We’ll be hosting a booth and a Session with <a href="http://research.microsoft.com/en-us/projects/contracts/default.aspx" target="_blank">Code
Contracts</a> at the <strong>PDC’09 conference</strong>. 
</p>
        <blockquote>
          <p>
            <a href="http://microsoftpdc.com/Sessions/VTL01">
              <strong>Code Contracts and Pex: Power
Charge your Assertions and Unit Tests</strong>
            </a>
            <br />
            <em>Come hear how Code Contracts provides a set of tools for design-by-contract programming
and how Pex is an advanced unit-testing tool that uses automated program exploration
to intelligently create unit tests with high code coverage. See how they work together
so that your code has fewer defects. Learn about new features for Code Contracts including
automatic documentation generation, call-site checking for components and reference
assemblies for the .NET Framework and for Pex including a light-weight mocking framework,
improved support for large code bases, and more thorough test input generation.</em>
          </p>
        </blockquote>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=176eec91-8426-4d06-8c68-46b9ad09c2ff" />
      </body>
      <title>Pex at PDC’09: Come to our Session (VTL01) and Booth</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,176eec91-8426-4d06-8c68-46b9ad09c2ff.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/ix21eHoaIa0/PexAtPDC09ComeToOurSessionVTL01AndBooth.aspx</link>
      <pubDate>Fri, 23 Oct 2009 02:14:52 GMT</pubDate>
      <description>&lt;p&gt;
We’ll be hosting a booth and a Session with &lt;a href="http://research.microsoft.com/en-us/projects/contracts/default.aspx" target="_blank"&gt;Code
Contracts&lt;/a&gt; at the &lt;strong&gt;PDC’09 conference&lt;/strong&gt;. 
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;a href="http://microsoftpdc.com/Sessions/VTL01"&gt;&lt;strong&gt;Code Contracts and Pex: Power
Charge your Assertions and Unit Tests&lt;/strong&gt;&lt;/a&gt;
&lt;br&gt;
&lt;em&gt;Come hear how Code Contracts provides a set of tools for design-by-contract programming
and how Pex is an advanced unit-testing tool that uses automated program exploration
to intelligently create unit tests with high code coverage. See how they work together
so that your code has fewer defects. Learn about new features for Code Contracts including
automatic documentation generation, call-site checking for components and reference
assemblies for the .NET Framework and for Pex including a light-weight mocking framework,
improved support for large code bases, and more thorough test input generation.&lt;/em&gt;
&lt;/p&gt;
&lt;/blockquote&gt;&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=176eec91-8426-4d06-8c68-46b9ad09c2ff" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,176eec91-8426-4d06-8c68-46b9ad09c2ff.aspx</comments>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/10/23/PexAtPDC09ComeToOurSessionVTL01AndBooth.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=959a8a8a-817f-4dec-a1b6-a30b0dd5ad36</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,959a8a8a-817f-4dec-a1b6-a30b0dd5ad36.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,959a8a8a-817f-4dec-a1b6-a30b0dd5ad36.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=959a8a8a-817f-4dec-a1b6-a30b0dd5ad36</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you have the chance to attend <a href="http://www.msteched.com/europe/Public/SessionList.aspx" target="_blank">Tech
Europe</a>, don’t forget to attend our session on <a href="http://research.microsoft.com/en-us/projects/contracts/default.aspx" target="_blank">Code
Contracts</a> and <a href="http://research.microsoft.com/pex" target="_blank">Pex</a> . <a href="http://blogs.msdn.com/nikolait" target="_blank">Nikolai
Tillmann</a> and I will also be attending a booth (on Code Contracts and Pex) during
the week. See you there.
</p>
        <blockquote>
          <p>
            <strong>DEV315 Code Contracts and Pex: Power Charge Your Assertions and Unit Tests<br />
Friday 11/13 – 13:00pm – 14:15pm.</strong>
          </p>
        </blockquote>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=959a8a8a-817f-4dec-a1b6-a30b0dd5ad36" />
      </body>
      <title>Pex at TechEd Europe: Session (DEV315) and Booth</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,959a8a8a-817f-4dec-a1b6-a30b0dd5ad36.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/1-u0DEzz-50/PexAtTechEdEuropeSessionDEV315AndBooth.aspx</link>
      <pubDate>Sat, 17 Oct 2009 00:23:51 GMT</pubDate>
      <description>&lt;p&gt;
If you have the chance to attend &lt;a href="http://www.msteched.com/europe/Public/SessionList.aspx" target="_blank"&gt;Tech
Europe&lt;/a&gt;, don’t forget to attend our session on &lt;a href="http://research.microsoft.com/en-us/projects/contracts/default.aspx" target="_blank"&gt;Code
Contracts&lt;/a&gt; and &lt;a href="http://research.microsoft.com/pex" target="_blank"&gt;Pex&lt;/a&gt; . &lt;a href="http://blogs.msdn.com/nikolait" target="_blank"&gt;Nikolai
Tillmann&lt;/a&gt; and I will also be attending a booth (on Code Contracts and Pex) during
the week. See you there.
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;strong&gt;DEV315 Code Contracts and Pex: Power Charge Your Assertions and Unit Tests&lt;br&gt;
Friday 11/13 – 13:00pm – 14:15pm.&lt;/strong&gt;
&lt;/p&gt;
&lt;/blockquote&gt;&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=959a8a8a-817f-4dec-a1b6-a30b0dd5ad36" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,959a8a8a-817f-4dec-a1b6-a30b0dd5ad36.aspx</comments>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/10/17/PexAtTechEdEuropeSessionDEV315AndBooth.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=68657a76-a7c6-421a-8321-41d201f54778</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,68657a76-a7c6-421a-8321-41d201f54778.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,68657a76-a7c6-421a-8321-41d201f54778.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=68657a76-a7c6-421a-8321-41d201f54778</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We have just release a new version of <a href="http://research.microsoft.com/pex" target="_blank">Pex</a> (v0.17.xxx)
which brings <strong>new features for Moles and more bug fixes</strong>.
</p>
        <p>
          <strong>Per-Instance Moles</strong>
        </p>
        <p>
Instance methods may be <em>moled</em> differently per object instance. This is particularly
useful when multiple instances of same type need to behave differently in the same
test. For example, let’s consider a simple class Bar that has a ‘Run’ method to check
that the values are not the same. The important point here is that we would not be
able to deal with such cases if we could not mole the behavior on a per-instance basis.
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_10.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_thumb_4.png" width="393" height="201" />
          </a>
        </p>
        <p>
In the test case of Run, we create to instance of MBar (the mole type of Bar) and
assign two different delegates to the ‘Value’ getter. Moles are active as soon as
they are attached (unlike the previous version) so we can just call the ‘Run’ method
once the moles are set up. In the code below, we are using the <a href="http://msdn.microsoft.com/en-us/library/bb384062.aspx" target="_blank">C#
Object Initializers</a> feature that allows us to set properties of a newly created
object within curly braces after the ‘new’ call.
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_12.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_thumb_5.png" width="448" height="249" />
          </a>
        </p>
        <p>
As you may have noticed, we just wrote a parameterized unit test that takes arbitrary
‘left’ and ‘right’ values. We then simply execute Pex to find the relevant values
to cover the ‘Run’ method:
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_14.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_thumb_6.png" width="425" height="74" />
          </a>
        </p>
        <p>
          <strong>Moles for Constructors</strong>
        </p>
        <p>
In same cases, objects created inside of other methods need to be moled to test the
actual program logic. With moles you can replace any constructor with your own delegate,
which you can use to attach a mole to the newly created instance. Let’s see this with
another simple example where a  ‘Run’ method creates and uses an instance of
a ‘Foo’ class.
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_4.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_thumb_1.png" width="363" height="263" />
          </a>
        </p>
        <p>
Let’s say we would like to mole the call to the ‘Value’ property to return any other
value. To do so, we would need to attach a mole to a future instance of Foo, and then
mole the Value property getter. This is exactly what is done in the method below.
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_6.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_thumb_2.png" width="293" height="231" />
          </a>
        </p>
        <p>
We then run Pex to find that 2 different values are needed to trigger all code paths.
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_8.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_thumb_3.png" width="427" height="85" />
          </a> 
</p>
        <p>
          <strong>Mole interface binding</strong>
        </p>
        <p>
All the member implementations of an interface may be moled at once using the new
‘Bind’ method. This smells like duck typing with type safety as the Bind methods are
strongly typed. For example, we want to mole a collection type (Foes) to return a
custom list of Foo elements (which need to be moled too). The goal is to test the
sum method…
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_16.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_thumb.png" width="309" height="232" />
          </a>
        </p>
        <p>
In the parameterized unit test case, we create an instance of Vector, which implements
IEnumerable&lt;int&gt;. Then, <strong>we can simply bind the ‘values’ array to the
mole </strong>to make Vector iterate over the array. The call to Bind will mole all
methods of MVector that are implemented by the ‘values’ parameters, effectively redirecting
all the enumeration requests to the ‘values’ array.
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_22.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_thumb_9.png" width="586" height="216" />
          </a>
        </p>
        <p>
When Pex runs through the sample, it correctly understand the data flow of the parameters
through the moles and finds inputs that break the ‘sum &gt;= 0’ assertion:
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_20.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_thumb_8.png" width="603" height="150" />
          </a>
        </p>
        <p>
          <strong>Compilation of Stubs assemblies</strong>
        </p>
        <p>
When one needs stubs or moles for a system assembly, it does not really make sense
to re-generate the stubs each time the solution is loaded. To that end, Stubs ships
with a command line tool that lets you easily compile a stubs assembly into a .dll:
</p>
        <blockquote>
          <p>
            <strong>stubs.exe mscorlib</strong>
          </p>
        </blockquote>
        <p>
Once the stubs assembly is compiled, i.e. mscorlib.Stubs.dll is created, you simply
have to add a reference to it in your test project to start using it. In future versions
of Pex, we will provide a better experience to support this scenario.
</p>
        <p>
          <strong>Bug Fixes</strong>
        </p>
        <ul>
          <li>
A number of fixes from the <a href="http://social.msdn.microsoft.com/Forums/en/pex/threads" target="_blank">issues
reported through the forums</a> and bugs reported to <a href="mailto:pexbug@microsoft.com">pexbug@microsoft.com</a> .</li>
        </ul>
        <p>
          <strong>Breaking Changes</strong>
        </p>
        <ul>
          <li>
The code generation of Moles was significantly changed. This might mean that you will
have to recompile your solution, and adapt all existing uses of Moles.</li>
        </ul>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=68657a76-a7c6-421a-8321-41d201f54778" />
      </body>
      <title>Pex v0.17.41006.7 : More Moles and Bug Fixes</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,68657a76-a7c6-421a-8321-41d201f54778.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/fe50u1afWx0/PexV017410067MoreMolesAndBugFixes.aspx</link>
      <pubDate>Wed, 07 Oct 2009 22:02:46 GMT</pubDate>
      <description>&lt;p&gt;
We have just release a new version of &lt;a href="http://research.microsoft.com/pex" target="_blank"&gt;Pex&lt;/a&gt; (v0.17.xxx)
which brings &lt;strong&gt;new features for Moles and more bug fixes&lt;/strong&gt;.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Per-Instance Moles&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Instance methods may be &lt;em&gt;moled&lt;/em&gt; differently per object instance. This is particularly
useful when multiple instances of same type need to behave differently in the same
test. For example, let’s consider a simple class Bar that has a ‘Run’ method to check
that the values are not the same. The important point here is that we would not be
able to deal with such cases if we could not mole the behavior on a per-instance basis.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_10.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_thumb_4.png" width="393" height="201"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
In the test case of Run, we create to instance of MBar (the mole type of Bar) and
assign two different delegates to the ‘Value’ getter. Moles are active as soon as
they are attached (unlike the previous version) so we can just call the ‘Run’ method
once the moles are set up. In the code below, we are using the &lt;a href="http://msdn.microsoft.com/en-us/library/bb384062.aspx" target="_blank"&gt;C#
Object Initializers&lt;/a&gt; feature that allows us to set properties of a newly created
object within curly braces after the ‘new’ call.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_12.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_thumb_5.png" width="448" height="249"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
As you may have noticed, we just wrote a parameterized unit test that takes arbitrary
‘left’ and ‘right’ values. We then simply execute Pex to find the relevant values
to cover the ‘Run’ method:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_14.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_thumb_6.png" width="425" height="74"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Moles for Constructors&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
In same cases, objects created inside of other methods need to be moled to test the
actual program logic. With moles you can replace any constructor with your own delegate,
which you can use to attach a mole to the newly created instance. Let’s see this with
another simple example where a&amp;nbsp; ‘Run’ method creates and uses an instance of
a ‘Foo’ class.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_thumb_1.png" width="363" height="263"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Let’s say we would like to mole the call to the ‘Value’ property to return any other
value. To do so, we would need to attach a mole to a future instance of Foo, and then
mole the Value property getter. This is exactly what is done in the method below.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_thumb_2.png" width="293" height="231"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
We then run Pex to find that 2 different values are needed to trigger all code paths.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_thumb_3.png" width="427" height="85"&gt;&lt;/a&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Mole interface binding&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
All the member implementations of an interface may be moled at once using the new
‘Bind’ method. This smells like duck typing with type safety as the Bind methods are
strongly typed. For example, we want to mole a collection type (Foes) to return a
custom list of Foo elements (which need to be moled too). The goal is to test the
sum method…
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_16.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_thumb.png" width="309" height="232"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
In the parameterized unit test case, we create an instance of Vector, which implements
IEnumerable&amp;lt;int&amp;gt;. Then, &lt;strong&gt;we can simply bind the ‘values’ array to the
mole &lt;/strong&gt;to make Vector iterate over the array. The call to Bind will mole all
methods of MVector that are implemented by the ‘values’ parameters, effectively redirecting
all the enumeration requests to the ‘values’ array.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_22.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_thumb_9.png" width="586" height="216"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
When Pex runs through the sample, it correctly understand the data flow of the parameters
through the moles and finds inputs that break the ‘sum &amp;gt;= 0’ assertion:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_20.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.17MoreMolesandBugFixes_D241/image_thumb_8.png" width="603" height="150"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Compilation of Stubs assemblies&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
When one needs stubs or moles for a system assembly, it does not really make sense
to re-generate the stubs each time the solution is loaded. To that end, Stubs ships
with a command line tool that lets you easily compile a stubs assembly into a .dll:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;strong&gt;stubs.exe mscorlib&lt;/strong&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Once the stubs assembly is compiled, i.e. mscorlib.Stubs.dll is created, you simply
have to add a reference to it in your test project to start using it. In future versions
of Pex, we will provide a better experience to support this scenario.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Bug Fixes&lt;/strong&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
A number of fixes from the &lt;a href="http://social.msdn.microsoft.com/Forums/en/pex/threads" target="_blank"&gt;issues
reported through the forums&lt;/a&gt; and bugs reported to &lt;a href="mailto:pexbug@microsoft.com"&gt;pexbug@microsoft.com&lt;/a&gt; .&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;strong&gt;Breaking Changes&lt;/strong&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
The code generation of Moles was significantly changed. This might mean that you will
have to recompile your solution, and adapt all existing uses of Moles.&lt;/li&gt;
&lt;/ul&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=68657a76-a7c6-421a-8321-41d201f54778" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,68657a76-a7c6-421a-8321-41d201f54778.aspx</comments>
      <category>Pex</category>
      <category>Stubs</category>
      <category>Testing</category>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/10/07/PexV017410067MoreMolesAndBugFixes.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=b2f6f612-c52f-49be-9a4d-c00b71e4e540</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,b2f6f612-c52f-49be-9a4d-c00b71e4e540.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,b2f6f612-c52f-49be-9a4d-c00b71e4e540.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=b2f6f612-c52f-49be-9a4d-c00b71e4e540</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://haacked.com/" target="_blank">Phil Haack</a> recently wrote <a href="http://haacked.com/archive/2009/09/29/moq-sequences.aspx" target="_blank">a
blog post</a> about a tricky use of <a href="http://code.google.com/p/moq/" target="_blank">Moq</a> where
one needs to set expectations for successive method calls. Here’s the specification
of the problem shamelessly copied from <a href="http://haacked.com/archive/2009/09/29/moq-sequences.aspx" target="_blank">his
blog post</a>:
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/SuccessiveMethodCallswithStubs_127EF/image_8.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/SuccessiveMethodCallswithStubs_127EF/image_thumb_3.png" width="573" height="250" />
          </a>
        </p>
        <p>
So we want to set up a mock to return 0 or more ‘true’ and a final false. With Moq <strong>and
the help of an extension method</strong>, Phil managed to express this in a single
line of C#.
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/SuccessiveMethodCallswithStubs_127EF/image_4.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/SuccessiveMethodCallswithStubs_127EF/image_thumb_1.png" width="579" height="166" />
          </a> 
</p>
        <p>
          <strong>Let’s do it with <a href="http://research.microsoft.com/stubs" target="_blank">Stubs</a>!</strong>
        </p>
        <p>
Stubs is a stub framework solely based on delegates. In that sense, it does not provide
any helper to express a sequence of calls so we need to do that in C#. An easy approach
is to create an array and use a counter to iterate through it (sounds familiar right?).
This is exactly that this snippet does:
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/SuccessiveMethodCallswithStubs_127EF/image_2.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/SuccessiveMethodCallswithStubs_127EF/image_thumb.png" width="334" height="109" />
          </a>
        </p>
        <p>
SIDataReader is the code generated stub type of IDataReader. It has a field Read of
type Func&lt;bool&gt; that can used to stub the Read() method.
</p>
        <p>
          <strong>Putting Pex into the mix</strong>
        </p>
        <p>
Why did we have to specify the values in the test? We should let <a href="http://research.microsoft.com/pex" target="_blank">Pex</a> decide
the sequence of booleans that are relevant to test code. To do so, we refactor values
as a parameter and add an <strong>assumption</strong> to ensure that the last element
is false.
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/SuccessiveMethodCallswithStubs_127EF/image_14.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/SuccessiveMethodCallswithStubs_127EF/image_thumb_6.png" width="473" height="264" />
          </a>
        </p>
        <p>
Voila!
</p>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=b2f6f612-c52f-49be-9a4d-c00b71e4e540" />
      </body>
      <title>Successive Method Calls with Stubs</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,b2f6f612-c52f-49be-9a4d-c00b71e4e540.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/sBUzG8zbFg0/SuccessiveMethodCallsWithStubs.aspx</link>
      <pubDate>Thu, 01 Oct 2009 05:36:55 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://haacked.com/" target="_blank"&gt;Phil Haack&lt;/a&gt; recently wrote &lt;a href="http://haacked.com/archive/2009/09/29/moq-sequences.aspx" target="_blank"&gt;a
blog post&lt;/a&gt; about a tricky use of &lt;a href="http://code.google.com/p/moq/" target="_blank"&gt;Moq&lt;/a&gt; where
one needs to set expectations for successive method calls. Here’s the specification
of the problem shamelessly copied from &lt;a href="http://haacked.com/archive/2009/09/29/moq-sequences.aspx" target="_blank"&gt;his
blog post&lt;/a&gt;:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/SuccessiveMethodCallswithStubs_127EF/image_8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/SuccessiveMethodCallswithStubs_127EF/image_thumb_3.png" width="573" height="250"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
So we want to set up a mock to return 0 or more ‘true’ and a final false. With Moq &lt;strong&gt;and
the help of an extension method&lt;/strong&gt;, Phil managed to express this in a single
line of C#.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/SuccessiveMethodCallswithStubs_127EF/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/SuccessiveMethodCallswithStubs_127EF/image_thumb_1.png" width="579" height="166"&gt;&lt;/a&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Let’s do it with &lt;a href="http://research.microsoft.com/stubs" target="_blank"&gt;Stubs&lt;/a&gt;!&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Stubs is a stub framework solely based on delegates. In that sense, it does not provide
any helper to express a sequence of calls so we need to do that in C#. An easy approach
is to create an array and use a counter to iterate through it (sounds familiar right?).
This is exactly that this snippet does:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/SuccessiveMethodCallswithStubs_127EF/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/SuccessiveMethodCallswithStubs_127EF/image_thumb.png" width="334" height="109"&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
SIDataReader is the code generated stub type of IDataReader. It has a field Read of
type Func&amp;lt;bool&amp;gt; that can used to stub the Read() method.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Putting Pex into the mix&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Why did we have to specify the values in the test? We should let &lt;a href="http://research.microsoft.com/pex" target="_blank"&gt;Pex&lt;/a&gt; decide
the sequence of booleans that are relevant to test code. To do so, we refactor values
as a parameter and add an &lt;strong&gt;assumption&lt;/strong&gt; to ensure that the last element
is false.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/SuccessiveMethodCallswithStubs_127EF/image_14.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/SuccessiveMethodCallswithStubs_127EF/image_thumb_6.png" width="473" height="264"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Voila!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=b2f6f612-c52f-49be-9a4d-c00b71e4e540" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,b2f6f612-c52f-49be-9a4d-c00b71e4e540.aspx</comments>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/10/01/SuccessiveMethodCallsWithStubs.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=ce09b012-e538-4c77-83b3-83d9f62cf259</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,ce09b012-e538-4c77-83b3-83d9f62cf259.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,ce09b012-e538-4c77-83b3-83d9f62cf259.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=ce09b012-e538-4c77-83b3-83d9f62cf259</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We just <a href="http://research.microsoft.com/en-us/projects/pex/downloads.aspx" target="_blank">released</a> v0.16.40915.5
of Pex. The major highlights of this release are <strong>Moles, a lightweight detour
framework, and better support for test frameworks</strong>.
</p>
        <ul>
          <li>
            <strong>Moles, a lightweight detour framework: </strong>Moles is a new extension of
the <a href="http://research.microsoft.com/stubs" target="_blank">Stubs framework</a>:
it lets you replace any .NET method (including static methods) with your own delegate.
Because an example is worth more than a thousand words, here is snippet that shows
how to make a static method (in this case, WCF OperationContext.Current) return a
predefined value:<br /><a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_11.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_thumb.png" width="577" height="226" /></a> <br />
Want read more about this sample? here is <a href="http://research.microsoft.com/en-us/projects/stubs/moles.aspx" target="_blank">the
full walkthrough</a>.<br />
The moles framework is not yet feature complete; moles does not support constructors
and external methods. Some types of mscorlib cannot be moled as they interact too
deeply with the CLR. 
</li>
          <li>
            <strong>Pex gets its own HostType: </strong>A HostType is a feature for the Visual
Studio Unit Test framework that lets specific unit tests be run under specialized
hosts such as Asp.Net or VisualStudio iself. In order to create reproducible test
cases using Moles, we had to implement a HostType that lets tests be run under the
Pex profiler. This is very exciting because it also opens the door for many uses of
Pex such as fault injection, dynamic checking, etc… in future versions of <a href="http://research.microsoft.com/pex" target="_blank">Pex</a>.
When generating test cases with Pex, all the necessary annotations will be created
automatically. To turn the Pex HostType on hand-written (non-parameterized) unit tests,
simply add <strong>[HostType(“Pex”)]</strong> on your test case.<br /><a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_20.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_thumb_9.png" width="242" height="108" /></a><strong> <br /></strong>This feature only works with Visual Studio Unit Test 2008. 
</li>
          <li>
            <strong>Select your test framework</strong>: the first time you invoke ‘Pex’ on your
code, Pex pops up a dialog to select your test framework of choice. You can select
which test framework should be used by default and, more importantly, where it can
be found on disk. 
<br /><a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_thumb_1.png" width="604" height="248" /></a><br />
If you do not use any test framework, Pex ships with what we call the <strong>“Direct
test framework”</strong>: in this “framework”, all methods are considered as unit
tests without any annotation or dependencies.<br /><a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_6.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_thumb_2.png" width="566" height="198" /></a> <br />
These settings are stored in the registry and Pex should not bug you again. If you
want to clear these settings, go to ‘Tools –&gt; Options –&gt; Pex –&gt; General’
and clear the TestFramework and TestFrameworkDirectory fields:<br /><a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_16.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_thumb_7.png" width="604" height="356" /></a>   
<br />
  
</li>
          <li>
            <strong>Thumbs up and down</strong>: We’ve added thumbs up and down buttons in the
Pex result view. <strong>We are always looking for feedback on Pex</strong>, so don’t
hesitate to click them when Pex deserves a thumbs up or a thumbs down.<br /><a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_18.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_thumb_8.png" width="604" height="76" /></a></li>
          <li>
            <strong>Performance</strong>: Many other performance improvements under the hood which
should avoid Pex hog too much memory in long running scenarios. 
</li>
          <li>
            <strong>Miscellanous improvements and bug fixes</strong>: 
<ul><li><strong>Support for String.GetHashCode():</strong> we now faithfully encode the hashing
function of strings, which means Pex can deal with dictionaries where the key is a
string. 
</li><li>
Fewer “Object Creation” messages that are not actually relevant. 
</li><li>
In VS 2010, the package used to trigger an exception when the solution loaded. This
issue is now fixed. 
</li><li>
In Visual Studio when an assembly had to be resolved manually (i.e. that little dialog
asking you where an assembly is), Pex remembers that choice and does not bug you anymore. 
</li><li>
And many other bugs that <a href="http://social.msdn.microsoft.com/Forums/en/pex/threads" target="_blank">were
reported through the forums</a>.</li></ul></li>
        </ul>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=ce09b012-e538-4c77-83b3-83d9f62cf259" />
      </body>
      <title>Pex 0.16.40915.5: Moles, a lightweight Detour Framework, and better support for Test Frameworks</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,ce09b012-e538-4c77-83b3-83d9f62cf259.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/zIv619RyMzE/Pex016409155MolesALightweightDetourFrameworkAndBetterSupportForTestFrameworks.aspx</link>
      <pubDate>Wed, 16 Sep 2009 21:16:33 GMT</pubDate>
      <description>&lt;p&gt;
We just &lt;a href="http://research.microsoft.com/en-us/projects/pex/downloads.aspx" target="_blank"&gt;released&lt;/a&gt; v0.16.40915.5
of Pex. The major highlights of this release are &lt;strong&gt;Moles, a lightweight detour
framework, and better support for test frameworks&lt;/strong&gt;.
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Moles, a lightweight detour framework: &lt;/strong&gt;Moles is a new extension of
the &lt;a href="http://research.microsoft.com/stubs" target="_blank"&gt;Stubs framework&lt;/a&gt;:
it lets you replace any .NET method (including static methods) with your own delegate.
Because an example is worth more than a thousand words, here is snippet that shows
how to make a static method (in this case, WCF OperationContext.Current) return a
predefined value:&lt;br&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_11.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_thumb.png" width="577" height="226"&gt;&lt;/a&gt;&amp;nbsp;&lt;br&gt;
Want read more about this sample? here is &lt;a href="http://research.microsoft.com/en-us/projects/stubs/moles.aspx" target="_blank"&gt;the
full walkthrough&lt;/a&gt;.&lt;br&gt;
The moles framework is not yet feature complete; moles does not support constructors
and external methods. Some types of mscorlib cannot be moled as they interact too
deeply with the CLR. 
&lt;li&gt;
&lt;strong&gt;Pex gets its own HostType: &lt;/strong&gt;A HostType is a feature for the Visual
Studio Unit Test framework that lets specific unit tests be run under specialized
hosts such as Asp.Net or VisualStudio iself. In order to create reproducible test
cases using Moles, we had to implement a HostType that lets tests be run under the
Pex profiler. This is very exciting because it also opens the door for many uses of
Pex such as fault injection, dynamic checking, etc… in future versions of &lt;a href="http://research.microsoft.com/pex" target="_blank"&gt;Pex&lt;/a&gt;.
When generating test cases with Pex, all the necessary annotations will be created
automatically. To turn the Pex HostType on hand-written (non-parameterized) unit tests,
simply add &lt;strong&gt;[HostType(“Pex”)]&lt;/strong&gt; on your test case.&lt;br&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_20.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_thumb_9.png" width="242" height="108"&gt;&lt;/a&gt;&lt;strong&gt;&amp;nbsp;&lt;br&gt;
&lt;/strong&gt;This feature only works with Visual Studio Unit Test 2008. 
&lt;li&gt;
&lt;strong&gt;Select your test framework&lt;/strong&gt;: the first time you invoke ‘Pex’ on your
code, Pex pops up a dialog to select your test framework of choice. You can select
which test framework should be used by default and, more importantly, where it can
be found on disk. 
&lt;br&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_thumb_1.png" width="604" height="248"&gt;&lt;/a&gt; 
&lt;br&gt;
If you do not use any test framework, Pex ships with what we call the &lt;strong&gt;“Direct
test framework”&lt;/strong&gt;: in this “framework”, all methods are considered as unit
tests without any annotation or dependencies.&lt;br&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_thumb_2.png" width="566" height="198"&gt;&lt;/a&gt;&amp;nbsp;&lt;br&gt;
These settings are stored in the registry and Pex should not bug you again. If you
want to clear these settings, go to ‘Tools –&amp;gt; Options –&amp;gt; Pex –&amp;gt; General’
and clear the TestFramework and TestFrameworkDirectory fields:&lt;br&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_16.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_thumb_7.png" width="604" height="356"&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp; 
&lt;li&gt;
&lt;strong&gt;Thumbs up and down&lt;/strong&gt;: We’ve added thumbs up and down buttons in the
Pex result view. &lt;strong&gt;We are always looking for feedback on Pex&lt;/strong&gt;, so don’t
hesitate to click them when Pex deserves a thumbs up or a thumbs down.&lt;br&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_18.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.16_733B/image_thumb_8.png" width="604" height="76"&gt;&lt;/a&gt; 
&lt;li&gt;
&lt;strong&gt;Performance&lt;/strong&gt;: Many other performance improvements under the hood which
should avoid Pex hog too much memory in long running scenarios. 
&lt;li&gt;
&lt;strong&gt;Miscellanous improvements and bug fixes&lt;/strong&gt;: 
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Support for String.GetHashCode():&lt;/strong&gt; we now faithfully encode the hashing
function of strings, which means Pex can deal with dictionaries where the key is a
string. 
&lt;li&gt;
Fewer “Object Creation” messages that are not actually relevant. 
&lt;li&gt;
In VS 2010, the package used to trigger an exception when the solution loaded. This
issue is now fixed. 
&lt;li&gt;
In Visual Studio when an assembly had to be resolved manually (i.e. that little dialog
asking you where an assembly is), Pex remembers that choice and does not bug you anymore. 
&lt;li&gt;
And many other bugs that &lt;a href="http://social.msdn.microsoft.com/Forums/en/pex/threads" target="_blank"&gt;were
reported through the forums&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=ce09b012-e538-4c77-83b3-83d9f62cf259" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,ce09b012-e538-4c77-83b3-83d9f62cf259.aspx</comments>
      <category>Code Contracts</category>
      <category>Pex</category>
      <category>Stubs</category>
      <category>Testing</category>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/09/16/Pex016409155MolesALightweightDetourFrameworkAndBetterSupportForTestFrameworks.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=01ef48c5-ba95-48d4-a1a8-49f32be29f1c</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,01ef48c5-ba95-48d4-a1a8-49f32be29f1c.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,01ef48c5-ba95-48d4-a1a8-49f32be29f1c.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=01ef48c5-ba95-48d4-a1a8-49f32be29f1c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://blogs.msdn.com/nikolait/archive/2008/10/24/pex-now-a-devlabs-project.aspx" target="_blank">Since
it’s been almost a year that we’ve released Pex</a>, we have started a little survey
on <a href="http://social.msdn.microsoft.com/Forums/en/pex/thread/27c703ea-3928-41ef-b767-638c39966b99" target="_blank">our
forums</a>. <strong>We are looking for feedback on how you use Pex and how you would
like to use it. </strong>If you are interested, please voice yourself  on our
mini survey at
</p>
        <blockquote>
          <p>
            <a title="http://social.msdn.microsoft.com/Forums/en/pex/thread/27c703ea-3928-41ef-b767-638c39966b99" href="http://social.msdn.microsoft.com/Forums/en/pex/thread/27c703ea-3928-41ef-b767-638c39966b99">
              <strong>http://social.msdn.microsoft.com/Forums/en/pex/thread/27c703ea-3928-41ef-b767-638c39966b99</strong>
            </a>
          </p>
        </blockquote>
        <p>
The questions are:
</p>
        <blockquote>
          <p>
1. Are you using Pex already? A) From Visual Studio, B) the command-line, C) other,
D) no<br />
2. Which version of Visual Studio are you using? A) Professional, B) Team System,
C) other<br />
3. How many people are in your team?<br />
4. Do you write A) Parameterized Unit Tests (PUTs), or B) only use the Wizard-generated
PUT stubs?
</p>
        </blockquote>
        <p>
Any other comments are appreciated as well, about the license terms, or required Visual
Studio versions…<br />
Thanks,  The <a href="http://research.microsoft.com/pex" target="_blank">Pex</a> Team
</p>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=01ef48c5-ba95-48d4-a1a8-49f32be29f1c" />
      </body>
      <title>How do you use Pex in Visual Studio? Your Input Is Needed!</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,01ef48c5-ba95-48d4-a1a8-49f32be29f1c.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/fZTbDf4zMOo/HowDoYouUsePexInVisualStudioYourInputIsNeeded.aspx</link>
      <pubDate>Wed, 09 Sep 2009 22:47:42 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://blogs.msdn.com/nikolait/archive/2008/10/24/pex-now-a-devlabs-project.aspx" target="_blank"&gt;Since
it’s been almost a year that we’ve released Pex&lt;/a&gt;, we have started a little survey
on &lt;a href="http://social.msdn.microsoft.com/Forums/en/pex/thread/27c703ea-3928-41ef-b767-638c39966b99" target="_blank"&gt;our
forums&lt;/a&gt;. &lt;strong&gt;We are looking for feedback on how you use Pex and how you would
like to use it. &lt;/strong&gt;If you are interested, please voice yourself&amp;nbsp; on our
mini survey at
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;a title="http://social.msdn.microsoft.com/Forums/en/pex/thread/27c703ea-3928-41ef-b767-638c39966b99" href="http://social.msdn.microsoft.com/Forums/en/pex/thread/27c703ea-3928-41ef-b767-638c39966b99"&gt;&lt;strong&gt;http://social.msdn.microsoft.com/Forums/en/pex/thread/27c703ea-3928-41ef-b767-638c39966b99&lt;/strong&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
The questions are:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
1. Are you using Pex already? A) From Visual Studio, B) the command-line, C) other,
D) no&lt;br&gt;
2. Which version of Visual Studio are you using? A) Professional, B) Team System,
C) other&lt;br&gt;
3. How many people are in your team?&lt;br&gt;
4. Do you write A) Parameterized Unit Tests (PUTs), or B) only use the Wizard-generated
PUT stubs?
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Any other comments are appreciated as well, about the license terms, or required Visual
Studio versions…&lt;br&gt;
Thanks,&amp;nbsp; The &lt;a href="http://research.microsoft.com/pex" target="_blank"&gt;Pex&lt;/a&gt; Team
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=01ef48c5-ba95-48d4-a1a8-49f32be29f1c" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,01ef48c5-ba95-48d4-a1a8-49f32be29f1c.aspx</comments>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/09/09/HowDoYouUsePexInVisualStudioYourInputIsNeeded.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=a95df4bb-aa7b-4bea-a6c1-f1df65ee8035</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,a95df4bb-aa7b-4bea-a6c1-f1df65ee8035.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,a95df4bb-aa7b-4bea-a6c1-f1df65ee8035.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=a95df4bb-aa7b-4bea-a6c1-f1df65ee8035</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
While on parental leave, I could sneak a couple hours to read a paper on <a href="http://portal.acm.org/citation.cfm?id=1089023.1089024" target="_blank">Frontier
Search</a> by Korf and al. Frontier search is a kind of <a href="http://en.wikipedia.org/wiki/Best-first_search" target="_blank">best-first
search</a> algorithm that reduces the needs for memory. A very interesting and relaxing
read… I add <a href="http://quickgraph.codeplex.com/SourceControl/changeset/view/36531#430731" target="_blank">an
implementation to QuickGraph</a> that follows the idea.
</p>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=a95df4bb-aa7b-4bea-a6c1-f1df65ee8035" />
      </body>
      <title>Best First Frontier Search in QuickGraph</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,a95df4bb-aa7b-4bea-a6c1-f1df65ee8035.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/sgx3k-GXHCs/BestFirstFrontierSearchInQuickGraph.aspx</link>
      <pubDate>Mon, 07 Sep 2009 05:17:05 GMT</pubDate>
      <description>&lt;p&gt;
While on parental leave, I could sneak a couple hours to read a paper on &lt;a href="http://portal.acm.org/citation.cfm?id=1089023.1089024" target="_blank"&gt;Frontier
Search&lt;/a&gt; by Korf and al. Frontier search is a kind of &lt;a href="http://en.wikipedia.org/wiki/Best-first_search" target="_blank"&gt;best-first
search&lt;/a&gt; algorithm that reduces the needs for memory. A very interesting and relaxing
read… I add &lt;a href="http://quickgraph.codeplex.com/SourceControl/changeset/view/36531#430731" target="_blank"&gt;an
implementation to QuickGraph&lt;/a&gt; that follows the idea.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=a95df4bb-aa7b-4bea-a6c1-f1df65ee8035" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,a95df4bb-aa7b-4bea-a6c1-f1df65ee8035.aspx</comments>
      <category>QuickGraph</category>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/09/07/BestFirstFrontierSearchInQuickGraph.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=94c22f9a-31dc-49ae-aa7d-d7a6450af152</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,94c22f9a-31dc-49ae-aa7d-d7a6450af152.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,94c22f9a-31dc-49ae-aa7d-d7a6450af152.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=94c22f9a-31dc-49ae-aa7d-d7a6450af152</wfw:commentRss>
      <slash:comments>5</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The new release of <a href="http://research.microsoft.com/en-us/projects/contracts/default.aspx" target="_blank">Code
Contracts</a> is out and brings a very cool feature: <strong><a href="http://channel9.msdn.com/posts/Peli/Xml-Documentation-from-Code-Contracts-for-Net/" target="_blank">Xml
comment generation</a>.</strong> This means that you do not have to worry about keeping
the comments in sync with the code, the compiler takes care of this.
</p>
        <p>
          <strong>Contracts to Xml Comments in action</strong>
        </p>
        <p>
Unless you invest a lot of work in them, Xml comments are most often worthless. For
example, in <a href="http://quickgraph.codeplex.com" target="_blank">QuickGraph</a>,
the documentation of the Edge constructor is really… well… useless (oops my fault):
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGraphdocumentationwithContracts_ECB9/image_6.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGraphdocumentationwithContracts_ECB9/image_thumb_2.png" width="604" height="184" />
          </a>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
However, the body of the constructor contains Contracts that state the pre-conditions
and post-conditions of the constructor: source and target should not be null, etc…
With the new xml comment generation, these contracts will be added to the xml documentation
and ultimately will show up in the compiled documentation. 
</p>
        <p>
First, let’s turn xml comment generation on in the property pages:
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGraphdocumentationwithContracts_ECB9/image_14.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGraphdocumentationwithContracts_ECB9/image_thumb_6.png" width="604" height="341" />
          </a>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
Once the project is rebuilt, we can take a look at the generated xml documentation
file. The ‘requires’ and ‘ensures’ elements are now under the Edge constructor element:
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGraphdocumentationwithContracts_ECB9/image_16.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGraphdocumentationwithContracts_ECB9/image_thumb_7.png" width="604" height="189" />
          </a>
        </p>
        <p>
Finally, we run the documentation file through Sandcastle<strong>***</strong> to get
the final result (make sure you update the Sandcastle stylesheets that come with Contracts.
Read section 8 of the <a href="http://research.microsoft.com/en-us/projects/contracts/userdoc.pdf" target="_blank">documentation</a>):
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGraphdocumentationwithContracts_ECB9/image_18.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGraphdocumentationwithContracts_ECB9/image_thumb_8.png" width="575" height="698" />
          </a>
        </p>
        <p>
Voila!<strong> With this feature, you have a documentation that never goes out of
date.</strong></p>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=94c22f9a-31dc-49ae-aa7d-d7a6450af152" />
      </body>
      <title>Code Contracts.Net to Xml Comments!</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,94c22f9a-31dc-49ae-aa7d-d7a6450af152.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/oaihcYhxfLg/CodeContractsNetToXmlComments.aspx</link>
      <pubDate>Sat, 05 Sep 2009 03:57:23 GMT</pubDate>
      <description>&lt;p&gt;
The new release of &lt;a href="http://research.microsoft.com/en-us/projects/contracts/default.aspx" target="_blank"&gt;Code
Contracts&lt;/a&gt; is out and brings a very cool feature: &lt;strong&gt;&lt;a href="http://channel9.msdn.com/posts/Peli/Xml-Documentation-from-Code-Contracts-for-Net/" target="_blank"&gt;Xml
comment generation&lt;/a&gt;.&lt;/strong&gt; This means that you do not have to worry about keeping
the comments in sync with the code, the compiler takes care of this.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Contracts to Xml Comments in action&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Unless you invest a lot of work in them, Xml comments are most often worthless. For
example, in &lt;a href="http://quickgraph.codeplex.com" target="_blank"&gt;QuickGraph&lt;/a&gt;,
the documentation of the Edge constructor is really… well… useless (oops my fault):
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGraphdocumentationwithContracts_ECB9/image_6.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGraphdocumentationwithContracts_ECB9/image_thumb_2.png" width="604" height="184"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
However, the body of the constructor contains Contracts that state the pre-conditions
and post-conditions of the constructor: source and target should not be null, etc…
With the new xml comment generation, these contracts will be added to the xml documentation
and ultimately will show up in the compiled documentation. 
&lt;/p&gt;
&lt;p&gt;
First, let’s turn xml comment generation on in the property pages:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGraphdocumentationwithContracts_ECB9/image_14.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGraphdocumentationwithContracts_ECB9/image_thumb_6.png" width="604" height="341"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Once the project is rebuilt, we can take a look at the generated xml documentation
file. The ‘requires’ and ‘ensures’ elements are now under the Edge constructor element:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGraphdocumentationwithContracts_ECB9/image_16.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGraphdocumentationwithContracts_ECB9/image_thumb_7.png" width="604" height="189"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Finally, we run the documentation file through Sandcastle&lt;strong&gt;***&lt;/strong&gt; to get
the final result (make sure you update the Sandcastle stylesheets that come with Contracts.
Read section 8 of the &lt;a href="http://research.microsoft.com/en-us/projects/contracts/userdoc.pdf" target="_blank"&gt;documentation&lt;/a&gt;):
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGraphdocumentationwithContracts_ECB9/image_18.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGraphdocumentationwithContracts_ECB9/image_thumb_8.png" width="575" height="698"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Voila!&lt;strong&gt; With this feature, you have a documentation that never goes out of
date.&lt;/strong&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=94c22f9a-31dc-49ae-aa7d-d7a6450af152" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,94c22f9a-31dc-49ae-aa7d-d7a6450af152.aspx</comments>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/09/05/CodeContractsNetToXmlComments.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=3f76f5dd-5139-4205-a716-d9c48af1ff6f</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,3f76f5dd-5139-4205-a716-d9c48af1ff6f.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,3f76f5dd-5139-4205-a716-d9c48af1ff6f.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=3f76f5dd-5139-4205-a716-d9c48af1ff6f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’ve just made a <a href="http://quickgraph.codeplex.com/Release/ProjectReleases.aspx" target="_blank">release</a> of <a href="http://quickgraph.codeplex.com" target="_blank">QuickGraph</a> 3.3
on CodePlex. Along with the usual bug fixes, this version brings a set of <strong>new
graph data structures based on delegates</strong>. Instead of taking care of the storage,
these graphs simply ‘query’ delegates for vertices and out-edges. You can use them
to bridge any existing graph data structure in your code with QuickGraph – with almost
no performance/memory penalty. (Delegate graphs can also be used to deal with graphs
that won’t hold in memory but that’s another story).
</p>
        <p>
Let’s see this with an example. Suppose, we have a simple graph representation using
a jagged array, <em>int[][]</em><em>graph</em>, where each edge is defined as <em>(i,
graph[i][j])</em> :
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGrap.3EasyinteropwithDelegateGraphs_787C/image_2.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGrap.3EasyinteropwithDelegateGraphs_787C/image_thumb.png" width="360" height="133" />
          </a>
        </p>
        <p>
In order to use this graph with QuickGraph, <strong>we ‘wrap’ it up into a delegate
graph</strong>. There are a number of extension methods in GraphExtensions that take
care of the common cases. Delegate graphs rely on 2 delegates: one that returns the
vertices, the other one out-edges: 
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGrap.3EasyinteropwithDelegateGraphs_787C/image_4.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGrap.3EasyinteropwithDelegateGraphs_787C/image_thumb_1.png" width="587" height="107" />
          </a>
        </p>
        <p>
At this point, we can apply any of the algorithms that QuickGraph provides. For example,
computing a topological sort of the vertices:
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGrap.3EasyinteropwithDelegateGraphs_787C/image_6.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGrap.3EasyinteropwithDelegateGraphs_787C/image_thumb_2.png" width="322" height="67" />
          </a> 
</p>
        <p>
The new delegate graphs are ready to be downloaded at <a href="http://quickgraph.codeplex.com/Release/ProjectReleases.aspx">http://quickgraph.codeplex.com/Release/ProjectReleases.aspx</a> .
</p>
        <p>
Happy programming!
</p>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=3f76f5dd-5139-4205-a716-d9c48af1ff6f" />
      </body>
      <title>QuickGraph 3.3: Easy interop with Delegate Graphs</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,3f76f5dd-5139-4205-a716-d9c48af1ff6f.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/fmRgDNAnjQw/QuickGraph33EasyInteropWithDelegateGraphs.aspx</link>
      <pubDate>Wed, 26 Aug 2009 15:34:18 GMT</pubDate>
      <description>&lt;p&gt;
I’ve just made a &lt;a href="http://quickgraph.codeplex.com/Release/ProjectReleases.aspx" target="_blank"&gt;release&lt;/a&gt; of &lt;a href="http://quickgraph.codeplex.com" target="_blank"&gt;QuickGraph&lt;/a&gt; 3.3
on CodePlex. Along with the usual bug fixes, this version brings a set of &lt;strong&gt;new
graph data structures based on delegates&lt;/strong&gt;. Instead of taking care of the storage,
these graphs simply ‘query’ delegates for vertices and out-edges. You can use them
to bridge any existing graph data structure in your code with QuickGraph – with almost
no performance/memory penalty. (Delegate graphs can also be used to deal with graphs
that won’t hold in memory but that’s another story).
&lt;/p&gt;
&lt;p&gt;
Let’s see this with an example. Suppose, we have a simple graph representation using
a jagged array, &lt;em&gt;int[][]&lt;/em&gt; &lt;em&gt;graph&lt;/em&gt;, where each edge is defined as &lt;em&gt;(i,
graph[i][j])&lt;/em&gt; :
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGrap.3EasyinteropwithDelegateGraphs_787C/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGrap.3EasyinteropwithDelegateGraphs_787C/image_thumb.png" width="360" height="133"&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
In order to use this graph with QuickGraph, &lt;strong&gt;we ‘wrap’ it up into a delegate
graph&lt;/strong&gt;. There are a number of extension methods in GraphExtensions that take
care of the common cases. Delegate graphs rely on 2 delegates: one that returns the
vertices, the other one out-edges: 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGrap.3EasyinteropwithDelegateGraphs_787C/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGrap.3EasyinteropwithDelegateGraphs_787C/image_thumb_1.png" width="587" height="107"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
At this point, we can apply any of the algorithms that QuickGraph provides. For example,
computing a topological sort of the vertices:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGrap.3EasyinteropwithDelegateGraphs_787C/image_6.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/QuickGrap.3EasyinteropwithDelegateGraphs_787C/image_thumb_2.png" width="322" height="67"&gt;&lt;/a&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
The new delegate graphs are ready to be downloaded at &lt;a href="http://quickgraph.codeplex.com/Release/ProjectReleases.aspx"&gt;http://quickgraph.codeplex.com/Release/ProjectReleases.aspx&lt;/a&gt; .
&lt;/p&gt;
&lt;p&gt;
Happy programming!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=3f76f5dd-5139-4205-a716-d9c48af1ff6f" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,3f76f5dd-5139-4205-a716-d9c48af1ff6f.aspx</comments>
      <category>QuickGraph</category>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/08/26/QuickGraph33EasyInteropWithDelegateGraphs.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=9b1c8401-8985-45b0-94b1-6d96031e6586</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,9b1c8401-8985-45b0-94b1-6d96031e6586.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,9b1c8401-8985-45b0-94b1-6d96031e6586.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=9b1c8401-8985-45b0-94b1-6d96031e6586</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We just <a href="http://research.microsoft.com/en-us/projects/pex/downloads.aspx">released
a new version of Pex, v0.15.40714.1</a>. This version does not contain any new features
but… it brings better memory management and bug fixes for <a href="http://social.msdn.microsoft.com/Forums/en/pex/threads">issues
that were reported through our MSDN forums</a>. Happy testing!
</p>
        <p>
It contains a couple breaking changes too:
</p>
        <ul>
          <li>
Microsoft.Pex.Stubs.dll does not exist anymore and has been integrated into Microsoft.Pex.Framework.dll 
</li>
          <li>
PexExplorableFromFactoriesAttribute renamed to PexExplorableFromFactoriesFromAssemblyAttribute</li>
        </ul>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=9b1c8401-8985-45b0-94b1-6d96031e6586" />
      </body>
      <title>Pex v0.15.40714.1: Better performance, less Bugs…</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,9b1c8401-8985-45b0-94b1-6d96031e6586.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/HJbMRHijw2A/PexV015407141BetterPerformanceLessBugs.aspx</link>
      <pubDate>Wed, 15 Jul 2009 22:11:19 GMT</pubDate>
      <description>&lt;p&gt;
We just &lt;a href="http://research.microsoft.com/en-us/projects/pex/downloads.aspx"&gt;released
a new version of Pex, v0.15.40714.1&lt;/a&gt;. This version does not contain any new features
but… it brings better memory management and bug fixes for &lt;a href="http://social.msdn.microsoft.com/Forums/en/pex/threads"&gt;issues
that were reported through our MSDN forums&lt;/a&gt;. Happy testing!
&lt;/p&gt;
&lt;p&gt;
It contains a couple breaking changes too:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Microsoft.Pex.Stubs.dll does not exist anymore and has been integrated into Microsoft.Pex.Framework.dll 
&lt;li&gt;
PexExplorableFromFactoriesAttribute renamed to PexExplorableFromFactoriesFromAssemblyAttribute&lt;/li&gt;
&lt;/ul&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=9b1c8401-8985-45b0-94b1-6d96031e6586" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,9b1c8401-8985-45b0-94b1-6d96031e6586.aspx</comments>
      <category>Pex</category>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/07/15/PexV015407141BetterPerformanceLessBugs.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=8128b319-4e2b-4a36-98b7-7b123a4d1bf5</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,8128b319-4e2b-4a36-98b7-7b123a4d1bf5.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,8128b319-4e2b-4a36-98b7-7b123a4d1bf5.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=8128b319-4e2b-4a36-98b7-7b123a4d1bf5</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We have just released a new version of <a href="http://research.microsoft.com/pex" target="_blank">Pex</a>,
v0.14.040610.2. This version brings a range of <strong>Bug Fixes</strong> that were
reported on the <a href="http://social.msdn.microsoft.com/Forums/en-US/pex/threads" target="_blank">MSDN
forums</a> and a couple new features: <strong>Fix Suggestions for Invariant Methods
and Natural properties  for </strong><a href="http://research.microsoft.com/stubs" target="_blank"><strong>Stubs</strong></a><strong>.</strong></p>
        <p>
          <b>Fix Suggestions for Invariant Methods</b>
        </p>
        <p>
When you use <a href="http://msdn.microsoft.com/en-us/devlabs/dd491992.aspx">Code
Contracts</a>, then Pex can now help you to add missing invariants, just as Pex already
inferred missing preconditions in the past. Take for example the ArrayList class that
comes with the <a href="http://research.microsoft.com/en-us/projects/pex/pexpublictutorialsamples.zip">samples</a> of
our recently updated <a href="http://research.microsoft.com/en-us/projects/pex/pexpublictutorialslides.pptx/">tutorial
slide deck</a>. This class has the following fields:
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/clip_image002_2.jpg">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/clip_image002_thumb.jpg" width="244" height="60" />
          </a>
        </p>
        <p>
When you add an empty invariant method,
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/clip_image004_2.jpg">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/clip_image004_thumb.jpg" width="240" height="58" />
          </a>
        </p>
        <p>
and enable Runtime Checking of contracts, then Pex will create instances of this class
using reflection while making sure that the invariants holds (we announced this feature
in the <a href="http://blogs.msdn.com/nikolait/archive/2009/05/28/pex-0-13-released-unit-tests-as-inputs-fuzzing-and-visual-studio-2010-beta-1-f-beta-1-support.aspx">last
release</a>). However, with an empty invariant method, Pex will be able to create
illegal states, e.g. where the _items array is null, which may cause a NullReferenceException,
and other issues. To get the following test cases, we let Pex explore the Add method
of our ArrayList class:
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/clip_image006_2.jpg">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image006" border="0" alt="clip_image006" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/clip_image006_thumb.jpg" width="627" height="149" />
          </a>
        </p>
        <p>
When you look at the details of the failing test cases, then you will see that Pex
now offers the option to add invariants directly into your [ContractInvariantMethod]:
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/image_8.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/image_thumb_3.png" width="581" height="204" />
          </a>
        </p>
        <p>
          <strong>Natural Properties for Stubs</strong>
        </p>
        <p>
The logic to handle properties with setters and getters generated by Stubs has been
slightly improved so that it is possible to force properties to have as if they had
a backing field.
</p>
        <p>
When a getter or a setter of a property is invoked, Stubs checks whether the getter
delegate or the setter delegates have been set. If not, i.e. no custom user behavior,
it queries the fallback behavior for an initial value of the property. If the fallback
behavior successfully returns a value, Stubs generates a closure and binds the getter
and setter.
</p>
        <p>
For example, here’s a simple IFoo interface with a Bar property:
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/image_2.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/image_thumb.png" width="242" height="81" />
          </a>
        </p>
        <p>
One could write the following parameterized unit test:
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/image_4.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/image_thumb_1.png" width="364" height="113" />
          </a>
        </p>
        <p>
Since we expect the Bar property to behave as it was wrapping a field, we don’t expect
the assertion to be raised. When we execute this test with Pex, and the Pex fallback
behavior, Pex will choose a value for ‘Bar’, and this value will be ‘stored’ the property.
Therefore, we get as expected 2 test cases:
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/image_6.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/image_thumb_2.png" width="210" height="78" />
          </a>
        </p>
        <p>
        </p>
        <p>
          <strong>Non default constructor support for Stubs</strong>
        </p>
        <p>
In previous versions, Stubs could not generate stubs for classes with no default constructor.
This is no longer the case, Stubs will generate one public constructor for each public
or protected base constructor.
</p>
        <p>
          <strong>Bug Fixes</strong>
        </p>
        <ul>
          <li>
Various code generation tweaks to make <a href="http://code.msdn.microsoft.com/sourceanalysis" target="_blank">StyleCop</a> happier 
</li>
          <li>
Visual Studio addin crashes when loading in VS2010 
</li>
          <li>
Visual Studio addin does not find attributes when they are globally qualified 
</li>
          <li>
Added missing substitutions for System.Threading.Interlocked members 
</li>
          <li>
Stubs automatically imports missing references 
</li>
          <li>
When an object has an invariant method (from Code <a href="http://research.microsoft.com/contracts" target="_blank">Contracts</a>),
Pex would emit assertions using the private fields 
</li>
          <li>
Editorial issues to patterns paper 
</li>
          <li>
Contracts no longer kill the process when the runtime rewriter was not executed (.net
4.0) 
</li>
          <li>
Fixed bug in generic type guesser 
</li>
          <li>
Fixed samples for the latest version of Stubs 
</li>
        </ul>
        <p>
          <strong>As always, don’t hesitate to send us your feedback, good or bad, through our <a href="http://social.msdn.microsoft.com/Forums/en-US/pex/threads/" target="_blank">MSDN
forums</a>.</strong>
        </p>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=8128b319-4e2b-4a36-98b7-7b123a4d1bf5" />
      </body>
      <title>Pex 0.14.040610.2: Fix Suggestions for Invariant Methods and Natural properties for Stubs.</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,8128b319-4e2b-4a36-98b7-7b123a4d1bf5.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/BLazwoMuZJI/Pex0140406102FixSuggestionsForInvariantMethodsAndNaturalPropertiesForStubs.aspx</link>
      <pubDate>Fri, 12 Jun 2009 02:14:58 GMT</pubDate>
      <description>&lt;p&gt;
We have just released a new version of &lt;a href="http://research.microsoft.com/pex" target="_blank"&gt;Pex&lt;/a&gt;,
v0.14.040610.2. This version brings a range of &lt;strong&gt;Bug Fixes&lt;/strong&gt; that were
reported on the &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/pex/threads" target="_blank"&gt;MSDN
forums&lt;/a&gt; and a couple new features: &lt;strong&gt;Fix Suggestions for Invariant Methods
and Natural properties&amp;#160; for &lt;/strong&gt;&lt;a href="http://research.microsoft.com/stubs" target="_blank"&gt;&lt;strong&gt;Stubs&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;.&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;b&gt;Fix Suggestions for Invariant Methods&lt;/b&gt;
&lt;/p&gt;
&lt;p&gt;
When you use &lt;a href="http://msdn.microsoft.com/en-us/devlabs/dd491992.aspx"&gt;Code
Contracts&lt;/a&gt;, then Pex can now help you to add missing invariants, just as Pex already
inferred missing preconditions in the past. Take for example the ArrayList class that
comes with the &lt;a href="http://research.microsoft.com/en-us/projects/pex/pexpublictutorialsamples.zip"&gt;samples&lt;/a&gt; of
our recently updated &lt;a href="http://research.microsoft.com/en-us/projects/pex/pexpublictutorialslides.pptx/"&gt;tutorial
slide deck&lt;/a&gt;. This class has the following fields:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/clip_image002_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/clip_image002_thumb.jpg" width="244" height="60" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
When you add an empty invariant method,
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/clip_image004_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/clip_image004_thumb.jpg" width="240" height="58" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
and enable Runtime Checking of contracts, then Pex will create instances of this class
using reflection while making sure that the invariants holds (we announced this feature
in the &lt;a href="http://blogs.msdn.com/nikolait/archive/2009/05/28/pex-0-13-released-unit-tests-as-inputs-fuzzing-and-visual-studio-2010-beta-1-f-beta-1-support.aspx"&gt;last
release&lt;/a&gt;). However, with an empty invariant method, Pex will be able to create
illegal states, e.g. where the _items array is null, which may cause a NullReferenceException,
and other issues. To get the following test cases, we let Pex explore the Add method
of our ArrayList class:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/clip_image006_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image006" border="0" alt="clip_image006" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/clip_image006_thumb.jpg" width="627" height="149" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
When you look at the details of the failing test cases, then you will see that Pex
now offers the option to add invariants directly into your [ContractInvariantMethod]:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/image_8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/image_thumb_3.png" width="581" height="204" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Natural Properties for Stubs&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
The logic to handle properties with setters and getters generated by Stubs has been
slightly improved so that it is possible to force properties to have as if they had
a backing field.
&lt;/p&gt;
&lt;p&gt;
When a getter or a setter of a property is invoked, Stubs checks whether the getter
delegate or the setter delegates have been set. If not, i.e. no custom user behavior,
it queries the fallback behavior for an initial value of the property. If the fallback
behavior successfully returns a value, Stubs generates a closure and binds the getter
and setter.
&lt;/p&gt;
&lt;p&gt;
For example, here’s a simple IFoo interface with a Bar property:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/image_thumb.png" width="242" height="81" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
One could write the following parameterized unit test:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/image_thumb_1.png" width="364" height="113" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Since we expect the Bar property to behave as it was wrapping a field, we don’t expect
the assertion to be raised. When we execute this test with Pex, and the Pex fallback
behavior, Pex will choose a value for ‘Bar’, and this value will be ‘stored’ the property.
Therefore, we get as expected 2 test cases:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex.xxBugfixesNaturalPropertiesandnondef_7CD8/image_thumb_2.png" width="210" height="78" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Non default constructor support for Stubs&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
In previous versions, Stubs could not generate stubs for classes with no default constructor.
This is no longer the case, Stubs will generate one public constructor for each public
or protected base constructor.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Bug Fixes&lt;/strong&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Various code generation tweaks to make &lt;a href="http://code.msdn.microsoft.com/sourceanalysis" target="_blank"&gt;StyleCop&lt;/a&gt; happier 
&lt;/li&gt;
&lt;li&gt;
Visual Studio addin crashes when loading in VS2010 
&lt;/li&gt;
&lt;li&gt;
Visual Studio addin does not find attributes when they are globally qualified 
&lt;/li&gt;
&lt;li&gt;
Added missing substitutions for System.Threading.Interlocked members 
&lt;/li&gt;
&lt;li&gt;
Stubs automatically imports missing references 
&lt;/li&gt;
&lt;li&gt;
When an object has an invariant method (from Code &lt;a href="http://research.microsoft.com/contracts" target="_blank"&gt;Contracts&lt;/a&gt;),
Pex would emit assertions using the private fields 
&lt;/li&gt;
&lt;li&gt;
Editorial issues to patterns paper 
&lt;/li&gt;
&lt;li&gt;
Contracts no longer kill the process when the runtime rewriter was not executed (.net
4.0) 
&lt;/li&gt;
&lt;li&gt;
Fixed bug in generic type guesser 
&lt;/li&gt;
&lt;li&gt;
Fixed samples for the latest version of Stubs 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;strong&gt;As always, don’t hesitate to send us your feedback, good or bad, through our &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/pex/threads/" target="_blank"&gt;MSDN
forums&lt;/a&gt;.&lt;/strong&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=8128b319-4e2b-4a36-98b7-7b123a4d1bf5" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,8128b319-4e2b-4a36-98b7-7b123a4d1bf5.aspx</comments>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/06/12/Pex0140406102FixSuggestionsForInvariantMethodsAndNaturalPropertiesForStubs.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=04c198f2-ca64-4e84-8fd5-e11fd04c4ad1</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,04c198f2-ca64-4e84-8fd5-e11fd04c4ad1.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,04c198f2-ca64-4e84-8fd5-e11fd04c4ad1.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=04c198f2-ca64-4e84-8fd5-e11fd04c4ad1</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://en.wikipedia.org/wiki/Inversion_of_control" target="_blank">Inversion
of Control</a> (IoC) is a very important practice to make code testable. It usually
relies on defining interfaces for each external dependency. Various frameworks and
techniques, i.e. <a href="http://en.wikipedia.org/wiki/Dependency_injection" target="_blank">Dependency
Injection</a> (DI), <a href="http://en.wikipedia.org/wiki/Service_locator_pattern" target="_blank">Service
Locator</a>, exist to bind the interface implementations to the components. In this
blog post, we will *not* focus on this aspects of IoC but rather on it’s main building
block: <em>interfaces</em>. This article describes how <strong>Contracts for interfaces
improves IoC… <em>regardless of which DI framework/technique you are using.</em></strong>The
Contracts for interfaces are a feature of the <a href="http://research.microsoft.com/contracts" target="_blank">Code
Contracts for .Net</a> tool.
</p>
        <h3>Interfaces are not Contracts
</h3>
        <p>
Interfaces are often referred to as <em>Contracts</em> in the context of IoC: they
define the methods and properties that a service should implement and are a key factor
in achieving the loose coupling: one can build the code against the interface and
can plug in various implementation with no risks.
</p>
        <p>
Unfortunately, <a href="http://blogs.msdn.com/kcwalina/archive/2004/10/24/246947.aspx" target="_blank">interfaces
are not contracts</a>: while they specify how the methods signatures should be, <strong>interfaces
do not specify the functional behavior</strong>. To illustrate this, let’s take a
look at a well-known simple interface of the BCL:
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/DependencyInjectionContractsforInterface_5E38/image_4.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/DependencyInjectionContractsforInterface_5E38/image_thumb_1.png" width="398" height="64" />
          </a>
        </p>
        <p>
For this interface, I could naively implement as follows:
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/DependencyInjectionContractsforInterface_5E38/image_6.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/DependencyInjectionContractsforInterface_5E38/image_thumb_2.png" width="406" height="93" />
          </a>
        </p>
        <p>
While my implementation is really really wrong, it fulfills all requirements of the
IServiceProvider interface: a method GetService that returns object. Of course, if
I would have read the MSDN documentation of GetService, I would have known that object
should implement serviceType. Unfortunately, the interface did not tell me anything
about that and compilers don’t understand MSDN documentation either. 
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/DependencyInjectionContractsforInterface_5E38/image_2.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/DependencyInjectionContractsforInterface_5E38/image_thumb.png" width="386" height="267" />
          </a> 
</p>
        <h3>Contracts for interfaces
</h3>
        <p>
Code Contracts provides <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.contracts(VS.100).aspx" target="_blank">an
API for design-by-contracts</a> (pre-condition, post-condition, etc…). It also supports
defining contracts for interface or abstract classes. <strong>Contracts for interfaces
can be used to specify the functional behavior of interface members.</strong> While
they also serve as documentation, those contracts can also be turned into runtime
checks or leveraged by static checkers. 
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/DependencyInjectionContractsforInterface_5E38/image_8.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/DependencyInjectionContractsforInterface_5E38/image_thumb_3.png" width="627" height="318" />
          </a>
        </p>
        <p>
        </p>
        <p>
        </p>
        <ul>
          <li>
since interface members cannot have method bodies, the contracts are stored in a ‘buddy’
type. 
</li>
          <li>
The [<a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.contracts.contractclassattribute(VS.100).aspx" target="_blank">ContractClass</a>]/[<a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.contracts.contractclassforattribute(VS.100).aspx" target="_blank">ContractClassFor</a>]
attributes bind the interface type and the contract type together. 
</li>
          <li>
            <a href="http://msdn.microsoft.com/en-us/library/dd412873(VS.100).aspx" target="_blank">Contract.Result&lt;object&gt;()</a> is
a helper method to refer to the result value, since this is not supported in C#. 
</li>
        </ul>
        <p>
Let’s take a closer look at the body of IServiceProviderContract.GetService. It contains
a pre-condition (Requires) that the serviceType should not be null and a post-condition
(Ensures) that the return value should be null or should be assignable to the serviceType:
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/DependencyInjectionContractsforInterface_5E38/image_10.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/DependencyInjectionContractsforInterface_5E38/image_thumb_4.png" width="561" height="96" />
          </a>
        </p>
        <p>
In this simple case, the contracts captured precisely the specification that we found
in MSDN. The critical difference is that they are stored in a format that compilers
and runtimes know pretty well: MSIL byte code. The benefits are huge:
</p>
        <ul>
          <li>
documentation: the contracts are stored in a programming-language agnostic format
that mined and rendered for your favorite programming language, 
</li>
          <li>
static checking: static analysis tools can (and will) use contract to try to find
bugs before you execute the code, or prove that it is correct with respect to the
contracts, 
</li>
          <li>
            <strong>runtime checking: the runtime checker will instrument all implementations
of the interface with the interface contracts <em>automatically</em>. </strong>Once
you’ve specified how an interface should behave, you do not have to repeat yourself
when re-implementing it, the re-writer takes care of that. 
</li>
          <li>
automated white box testing:<strong />tools like <a href="http://research.microsoft.com/pex" target="_blank">Pex</a> can
leverage the runtime contract checks to try to find inputs that violate the contracts. 
</li>
          <li>
            <strong>IoC/DI framework agnostic: </strong>It does not matter which DI framework
you use, as soon as you use interface, you could also provide contracts for it. 
</li>
        </ul>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=04c198f2-ca64-4e84-8fd5-e11fd04c4ad1" />
      </body>
      <title>Specifying Inversion of Control through Contracts for Interfaces</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,04c198f2-ca64-4e84-8fd5-e11fd04c4ad1.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/oG0124nXCiM/SpecifyingInversionOfControlThroughContractsForInterfaces.aspx</link>
      <pubDate>Wed, 03 Jun 2009 00:14:03 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://en.wikipedia.org/wiki/Inversion_of_control" target="_blank"&gt;Inversion
of Control&lt;/a&gt; (IoC) is a very important practice to make code testable. It usually
relies on defining interfaces for each external dependency. Various frameworks and
techniques, i.e. &lt;a href="http://en.wikipedia.org/wiki/Dependency_injection" target="_blank"&gt;Dependency
Injection&lt;/a&gt; (DI), &lt;a href="http://en.wikipedia.org/wiki/Service_locator_pattern" target="_blank"&gt;Service
Locator&lt;/a&gt;, exist to bind the interface implementations to the components. In this
blog post, we will *not* focus on this aspects of IoC but rather on it’s main building
block: &lt;em&gt;interfaces&lt;/em&gt;. This article describes how &lt;strong&gt;Contracts for interfaces
improves IoC… &lt;em&gt;regardless of which DI framework/technique you are using.&lt;/em&gt; &lt;/strong&gt;The
Contracts for interfaces are a feature of the &lt;a href="http://research.microsoft.com/contracts" target="_blank"&gt;Code
Contracts for .Net&lt;/a&gt; tool.
&lt;/p&gt;
&lt;h3&gt;Interfaces are not Contracts
&lt;/h3&gt;
&lt;p&gt;
Interfaces are often referred to as &lt;em&gt;Contracts&lt;/em&gt; in the context of IoC: they
define the methods and properties that a service should implement and are a key factor
in achieving the loose coupling: one can build the code against the interface and
can plug in various implementation with no risks.
&lt;/p&gt;
&lt;p&gt;
Unfortunately, &lt;a href="http://blogs.msdn.com/kcwalina/archive/2004/10/24/246947.aspx" target="_blank"&gt;interfaces
are not contracts&lt;/a&gt;: while they specify how the methods signatures should be, &lt;strong&gt;interfaces
do not specify the functional behavior&lt;/strong&gt;. To illustrate this, let’s take a
look at a well-known simple interface of the BCL:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/DependencyInjectionContractsforInterface_5E38/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/DependencyInjectionContractsforInterface_5E38/image_thumb_1.png" width="398" height="64" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
For this interface, I could naively implement as follows:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/DependencyInjectionContractsforInterface_5E38/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/DependencyInjectionContractsforInterface_5E38/image_thumb_2.png" width="406" height="93" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
While my implementation is really really wrong, it fulfills all requirements of the
IServiceProvider interface: a method GetService that returns object. Of course, if
I would have read the MSDN documentation of GetService, I would have known that object
should implement serviceType. Unfortunately, the interface did not tell me anything
about that and compilers don’t understand MSDN documentation either. 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/DependencyInjectionContractsforInterface_5E38/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/DependencyInjectionContractsforInterface_5E38/image_thumb.png" width="386" height="267" /&gt;&lt;/a&gt;&amp;#160;
&lt;/p&gt;
&lt;h3&gt;Contracts for interfaces
&lt;/h3&gt;
&lt;p&gt;
Code Contracts provides &lt;a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.contracts(VS.100).aspx" target="_blank"&gt;an
API for design-by-contracts&lt;/a&gt; (pre-condition, post-condition, etc…). It also supports
defining contracts for interface or abstract classes. &lt;strong&gt;Contracts for interfaces
can be used to specify the functional behavior of interface members.&lt;/strong&gt; While
they also serve as documentation, those contracts can also be turned into runtime
checks or leveraged by static checkers. 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/DependencyInjectionContractsforInterface_5E38/image_8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/DependencyInjectionContractsforInterface_5E38/image_thumb_3.png" width="627" height="318" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
since interface members cannot have method bodies, the contracts are stored in a ‘buddy’
type. 
&lt;/li&gt;
&lt;li&gt;
The [&lt;a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.contracts.contractclassattribute(VS.100).aspx" target="_blank"&gt;ContractClass&lt;/a&gt;]/[&lt;a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.contracts.contractclassforattribute(VS.100).aspx" target="_blank"&gt;ContractClassFor&lt;/a&gt;]
attributes bind the interface type and the contract type together. 
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/dd412873(VS.100).aspx" target="_blank"&gt;Contract.Result&amp;lt;object&amp;gt;()&lt;/a&gt; is
a helper method to refer to the result value, since this is not supported in C#. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Let’s take a closer look at the body of IServiceProviderContract.GetService. It contains
a pre-condition (Requires) that the serviceType should not be null and a post-condition
(Ensures) that the return value should be null or should be assignable to the serviceType:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/DependencyInjectionContractsforInterface_5E38/image_10.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/DependencyInjectionContractsforInterface_5E38/image_thumb_4.png" width="561" height="96" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
In this simple case, the contracts captured precisely the specification that we found
in MSDN. The critical difference is that they are stored in a format that compilers
and runtimes know pretty well: MSIL byte code. The benefits are huge:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
documentation: the contracts are stored in a programming-language agnostic format
that mined and rendered for your favorite programming language, 
&lt;/li&gt;
&lt;li&gt;
static checking: static analysis tools can (and will) use contract to try to find
bugs before you execute the code, or prove that it is correct with respect to the
contracts, 
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;runtime checking: the runtime checker will instrument all implementations
of the interface with the interface contracts &lt;em&gt;automatically&lt;/em&gt;. &lt;/strong&gt;Once
you’ve specified how an interface should behave, you do not have to repeat yourself
when re-implementing it, the re-writer takes care of that. 
&lt;/li&gt;
&lt;li&gt;
automated white box testing:&lt;strong&gt; &lt;/strong&gt;tools like &lt;a href="http://research.microsoft.com/pex" target="_blank"&gt;Pex&lt;/a&gt; can
leverage the runtime contract checks to try to find inputs that violate the contracts. 
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IoC/DI framework agnostic: &lt;/strong&gt;It does not matter which DI framework
you use, as soon as you use interface, you could also provide contracts for it. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=04c198f2-ca64-4e84-8fd5-e11fd04c4ad1" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,04c198f2-ca64-4e84-8fd5-e11fd04c4ad1.aspx</comments>
      <category>Code Contracts</category>
      <category>Testing</category>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/06/03/SpecifyingInversionOfControlThroughContractsForInterfaces.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=c08175a6-efc8-4452-b7dc-92346a3033de</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,c08175a6-efc8-4452-b7dc-92346a3033de.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,c08175a6-efc8-4452-b7dc-92346a3033de.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=c08175a6-efc8-4452-b7dc-92346a3033de</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We’ve just released the <a href="http://research.microsoft.com/en-us/projects/pex/downloads.aspx" target="_blank">Pex
0.13.40528.2</a> (Nikolai <a href="http://blogs.msdn.com/nikolait/archive/2009/05/28/pex-0-13-released-unit-tests-as-inputs-fuzzing-and-visual-studio-2010-beta-1-f-beta-1-support.aspx" target="_blank">has
all the details about the new features</a>). In this release, a number of attributes
were added to force Pex produce more friendly inputs.
</p>
        <p>
          <strong>The problem with Enums</strong>
        </p>
        <p>
When you apply <a href="http://research.microsoft.com/pex" target="_blank">Pex</a> to
code that uses Enumerations, you quickly learn something: the CLR does not constraints
the enumeration values to be defined. This means than whenever you take an Enum as
a parameter, you should validate it is properly defined: 
</p>
        <blockquote>
          <p>
void Test(SomeEnum e) { 
<br />
    if (!Enum.IsDefined(typeof(SomeEnum), e)) throw new ArgumentException(“…”); 
<br />
}
</p>
        </blockquote>
        <p>
Look at the BCL code, they actually do this kind of validation. For good or bad, some
of our users have been complaining that Pex should restrict the enumeration to defined
values, in fact considering the generated failing test case as <em>noise</em>. To
restrict generated enumartion values to be defined, you can add the <strong>[PexEnumValuesDefined(typeof(SomeEnum))]</strong> attribute
on your test/fixture/assembly. Internally, this attribute attaches an invariant to
the given enumeration type that tells <a href="http://research.microsoft.com/en-us/um/redmond/projects/z3/" target="_blank">Z3</a> the
allowed values for that type.
</p>
        <p>
          <strong>What about multi-dimensional arrays</strong>?
</p>
        <p>
Ever wakened a day wanting to iterate arrays starting from –12345? Well you can with
multidimensional arrays… The Array.CreateInstance method has an overload that takes
length and <em>lower bounds</em> to instantiate multidimensional arrays:
</p>
        <blockquote>
          <p>
int[,] array = (int[,])Array.CreateInstance(typeof(int), 
<br />
    new int[] {10, 10}, // lengths 
<br /><strong>    new int[] {–12345, – 789} // lower bounds 
<br />
    </strong>); 
<br />
a[<strong>-12345, –789</strong>] = –1;
</p>
        </blockquote>
        <p>
Of course, this feels a bit weird because most languages won’t allow to create such
arrays, but the Array.CreateInstance method is still available nonetheless. It feels
a bit weird but this behavior is perfectly valid from the runtime point of view. To
restrict Pex from generating such bounds, you can add the <strong>[PexZeroMdArrayLowerBounds(0)]</strong> attribute
(one attribute per dimension).
</p>
        <p>
          <strong>What about Booleans?</strong>
        </p>
        <p>
Booleans is another interesting citizen of the CLR. At the MSIL level, the Boolean
type is really a byte, widened as an integer when on the stack. Compilers try really
hard to keep Booleans as 0 or 1 but… it is possible to craft Boolean values anywhere
the byte range <em>using safe MSIL code </em>(not from C# though or any BCL method
I know of). The implication of this are quite disturbing, for example, consider the
following parameterized test:
</p>
        <blockquote>
          <p>
[PexMethod] { 
<br />
void BooleanMadness(bool a, bool b) { 
<br /><strong>     if (a &amp;&amp; b &amp;&amp; a != b) 
<br /></strong>         throw new Exception(“this
is madness!”); 
<br />
}
</p>
        </blockquote>
        <p>
Clearly, in a word of Booleans constrained to 0 or 1, the branch that throws the exception
should be unreachable. If you execute Pex on this test, it will generate 4 test<strong> one
of which raises the exception:</strong></p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/TamingthePexWellbehavedenumsandbooleans_E75/image_2.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/TamingthePexWellbehavedenumsandbooleans_E75/image_thumb.png" width="399" height="115" />
          </a>  
</p>
        <p>
Notice the actual values (0x02, 0x03) of the Booleans in the pretty printing. If you
want Pex to generate Boolean that are restricted to 0 or 1, use the <strong>[PexBooleanAsZeroOrOne]</strong> attribute.
This attribute forces Z3 to pick boolean values as 0 or 1. Btw, there’s already a <a href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=455553" target="_blank">connect
bug</a> for this behavior.
</p>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=c08175a6-efc8-4452-b7dc-92346a3033de" />
      </body>
      <title>Taming the Pex beast: Well-behaved enums, multi-dimensional arrays and booleans</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,c08175a6-efc8-4452-b7dc-92346a3033de.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/0p6V3DgowB8/TamingThePexBeastWellbehavedEnumsMultidimensionalArraysAndBooleans.aspx</link>
      <pubDate>Fri, 29 May 2009 00:06:06 GMT</pubDate>
      <description>&lt;p&gt;
We’ve just released the &lt;a href="http://research.microsoft.com/en-us/projects/pex/downloads.aspx" target="_blank"&gt;Pex
0.13.40528.2&lt;/a&gt; (Nikolai &lt;a href="http://blogs.msdn.com/nikolait/archive/2009/05/28/pex-0-13-released-unit-tests-as-inputs-fuzzing-and-visual-studio-2010-beta-1-f-beta-1-support.aspx" target="_blank"&gt;has
all the details about the new features&lt;/a&gt;). In this release, a number of attributes
were added to force Pex produce more friendly inputs.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;The problem with Enums&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
When you apply &lt;a href="http://research.microsoft.com/pex" target="_blank"&gt;Pex&lt;/a&gt; to
code that uses Enumerations, you quickly learn something: the CLR does not constraints
the enumeration values to be defined. This means than whenever you take an Enum as
a parameter, you should validate it is properly defined: 
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
void Test(SomeEnum e) { 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; if (!Enum.IsDefined(typeof(SomeEnum), e)) throw new ArgumentException(“…”); 
&lt;br /&gt;
}
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Look at the BCL code, they actually do this kind of validation. For good or bad, some
of our users have been complaining that Pex should restrict the enumeration to defined
values, in fact considering the generated failing test case as &lt;em&gt;noise&lt;/em&gt;. To
restrict generated enumartion values to be defined, you can add the &lt;strong&gt;[PexEnumValuesDefined(typeof(SomeEnum))]&lt;/strong&gt; attribute
on your test/fixture/assembly. Internally, this attribute attaches an invariant to
the given enumeration type that tells &lt;a href="http://research.microsoft.com/en-us/um/redmond/projects/z3/" target="_blank"&gt;Z3&lt;/a&gt; the
allowed values for that type.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;What about multi-dimensional arrays&lt;/strong&gt;?
&lt;/p&gt;
&lt;p&gt;
Ever wakened a day wanting to iterate arrays starting from –12345? Well you can with
multidimensional arrays… The Array.CreateInstance method has an overload that takes
length and &lt;em&gt;lower bounds&lt;/em&gt; to instantiate multidimensional arrays:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
int[,] array = (int[,])Array.CreateInstance(typeof(int), 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; new int[] {10, 10}, // lengths 
&lt;br /&gt;
&lt;strong&gt;&amp;#160;&amp;#160;&amp;#160; new int[] {–12345, – 789} // lower bounds 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160; &lt;/strong&gt;); 
&lt;br /&gt;
a[&lt;strong&gt;-12345, –789&lt;/strong&gt;] = –1;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Of course, this feels a bit weird because most languages won’t allow to create such
arrays, but the Array.CreateInstance method is still available nonetheless. It feels
a bit weird but this behavior is perfectly valid from the runtime point of view. To
restrict Pex from generating such bounds, you can add the &lt;strong&gt;[PexZeroMdArrayLowerBounds(0)]&lt;/strong&gt; attribute
(one attribute per dimension).
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;What about Booleans?&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Booleans is another interesting citizen of the CLR. At the MSIL level, the Boolean
type is really a byte, widened as an integer when on the stack. Compilers try really
hard to keep Booleans as 0 or 1 but… it is possible to craft Boolean values anywhere
the byte range &lt;em&gt;using safe MSIL code &lt;/em&gt;(not from C# though or any BCL method
I know of). The implication of this are quite disturbing, for example, consider the
following parameterized test:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
[PexMethod] { 
&lt;br /&gt;
void BooleanMadness(bool a, bool b) { 
&lt;br /&gt;
&lt;strong&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (a &amp;amp;&amp;amp; b &amp;amp;&amp;amp; a != b) 
&lt;br /&gt;
&lt;/strong&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; throw new Exception(“this
is madness!”); 
&lt;br /&gt;
}
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Clearly, in a word of Booleans constrained to 0 or 1, the branch that throws the exception
should be unreachable. If you execute Pex on this test, it will generate 4 test&lt;strong&gt; one
of which raises the exception:&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/TamingthePexWellbehavedenumsandbooleans_E75/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/TamingthePexWellbehavedenumsandbooleans_E75/image_thumb.png" width="399" height="115" /&gt;&lt;/a&gt;&amp;#160; 
&lt;/p&gt;
&lt;p&gt;
Notice the actual values (0x02, 0x03) of the Booleans in the pretty printing. If you
want Pex to generate Boolean that are restricted to 0 or 1, use the &lt;strong&gt;[PexBooleanAsZeroOrOne]&lt;/strong&gt; attribute.
This attribute forces Z3 to pick boolean values as 0 or 1. Btw, there’s already a &lt;a href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=455553" target="_blank"&gt;connect
bug&lt;/a&gt; for this behavior.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=c08175a6-efc8-4452-b7dc-92346a3033de" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,c08175a6-efc8-4452-b7dc-92346a3033de.aspx</comments>
      <category>Pex</category>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/05/29/TamingThePexBeastWellbehavedEnumsMultidimensionalArraysAndBooleans.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=7c424777-4325-431a-9173-f306c3e29abd</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,7c424777-4325-431a-9173-f306c3e29abd.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,7c424777-4325-431a-9173-f306c3e29abd.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=7c424777-4325-431a-9173-f306c3e29abd</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you’ve been thinking about presenting <a href="http://research.microsoft.com/pex" target="_blank">Pex</a> to
your co-workers or your local .NET community, you can use our slide decks at <a title="http://research.microsoft.com/en-us/projects/pex/documentation.aspx" href="http://research.microsoft.com/en-us/projects/pex/documentation.aspx">http://research.microsoft.com/en-us/projects/pex/documentation.aspx</a> .
The slide decks are there to help you, don’t hesitate to shuffle them, cut them or
pick whatever you need in them (and of course, tell us about it).
</p>
        <p>
Cheers, Peli.
</p>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=7c424777-4325-431a-9173-f306c3e29abd" />
      </body>
      <title>Presenting Pex to your co-workers? Use our slide decks…</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,7c424777-4325-431a-9173-f306c3e29abd.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/0aqSZP7FNbg/PresentingPexToYourCoworkersUseOurSlideDecks.aspx</link>
      <pubDate>Tue, 26 May 2009 05:54:47 GMT</pubDate>
      <description>&lt;p&gt;
If you’ve been thinking about presenting &lt;a href="http://research.microsoft.com/pex" target="_blank"&gt;Pex&lt;/a&gt; to
your co-workers or your local .NET community, you can use our slide decks at &lt;a title="http://research.microsoft.com/en-us/projects/pex/documentation.aspx" href="http://research.microsoft.com/en-us/projects/pex/documentation.aspx"&gt;http://research.microsoft.com/en-us/projects/pex/documentation.aspx&lt;/a&gt; .
The slide decks are there to help you, don’t hesitate to shuffle them, cut them or
pick whatever you need in them (and of course, tell us about it).
&lt;/p&gt;
&lt;p&gt;
Cheers, Peli.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=7c424777-4325-431a-9173-f306c3e29abd" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,7c424777-4325-431a-9173-f306c3e29abd.aspx</comments>
      <category>Pex</category>
      <category>Testing</category>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/05/26/PresentingPexToYourCoworkersUseOurSlideDecks.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=04862018-38f9-4562-8b68-7b2a067ea3a1</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,04862018-38f9-4562-8b68-7b2a067ea3a1.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,04862018-38f9-4562-8b68-7b2a067ea3a1.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=04862018-38f9-4562-8b68-7b2a067ea3a1</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you are (or you've been) blogging about Pex, let us know and drop the link in this
following forum thread: 
</p>
        <blockquote>
          <p>
            <a title="http://social.msdn.microsoft.com/Forums/en-US/pex/thread/7e6c26df-ccfb-48a4-878d-b3b01f5ba8d5" href="http://social.msdn.microsoft.com/Forums/en-US/pex/thread/7e6c26df-ccfb-48a4-878d-b3b01f5ba8d5">http://social.msdn.microsoft.com/Forums/en-US/pex/thread/7e6c26df-ccfb-48a4-878d-b3b01f5ba8d5</a>
          </p>
        </blockquote>
        <p>
We are building a list of links that will be hosted our project web site.
</p>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=04862018-38f9-4562-8b68-7b2a067ea3a1" />
      </body>
      <title>Blogging about Pex, let us know!</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,04862018-38f9-4562-8b68-7b2a067ea3a1.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/dqCL0FJUXOE/BloggingAboutPexLetUsKnow.aspx</link>
      <pubDate>Wed, 20 May 2009 14:26:22 GMT</pubDate>
      <description>&lt;p&gt;
If you are (or you've been) blogging about Pex, let us know and drop the link in this
following forum thread: 
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;a title="http://social.msdn.microsoft.com/Forums/en-US/pex/thread/7e6c26df-ccfb-48a4-878d-b3b01f5ba8d5" href="http://social.msdn.microsoft.com/Forums/en-US/pex/thread/7e6c26df-ccfb-48a4-878d-b3b01f5ba8d5"&gt;http://social.msdn.microsoft.com/Forums/en-US/pex/thread/7e6c26df-ccfb-48a4-878d-b3b01f5ba8d5&lt;/a&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
We are building a list of links that will be hosted our project web site.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=04862018-38f9-4562-8b68-7b2a067ea3a1" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,04862018-38f9-4562-8b68-7b2a067ea3a1.aspx</comments>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/05/20/BloggingAboutPexLetUsKnow.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=f00fef7c-c211-4541-836c-dbe0b60ec719</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,f00fef7c-c211-4541-836c-dbe0b60ec719.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,f00fef7c-c211-4541-836c-dbe0b60ec719.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=f00fef7c-c211-4541-836c-dbe0b60ec719</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Not sure what’s going to come up at of this but you can find me on twitter at <a title="http://twitter.com/pelikhan" href="http://twitter.com/pelikhan">http://twitter.com/pelikhan</a>.
</p>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=f00fef7c-c211-4541-836c-dbe0b60ec719" />
      </body>
      <title>find me at http://twitter.com/pelikhan</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,f00fef7c-c211-4541-836c-dbe0b60ec719.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/t3d3esxTQeo/findMeAtHttptwittercompelikhan.aspx</link>
      <pubDate>Sat, 16 May 2009 13:06:55 GMT</pubDate>
      <description>&lt;p&gt;
Not sure what’s going to come up at of this but you can find me on twitter at &lt;a title="http://twitter.com/pelikhan" href="http://twitter.com/pelikhan"&gt;http://twitter.com/pelikhan&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=f00fef7c-c211-4541-836c-dbe0b60ec719" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,f00fef7c-c211-4541-836c-dbe0b60ec719.aspx</comments>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/05/16/findMeAtHttptwittercompelikhan.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=bbda23d8-9f56-4ce8-96b1-b222841d2093</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,bbda23d8-9f56-4ce8-96b1-b222841d2093.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,bbda23d8-9f56-4ce8-96b1-b222841d2093.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=bbda23d8-9f56-4ce8-96b1-b222841d2093</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This is a cool new feature that builds on <a href="http://research.microsoft.com/stubs" target="_blank">Stubs</a>, <a href="http://research.microsoft.com/pex" target="_blank">Pex</a> 
and Code <a href="http://research.microsoft.com/contracts" target="_blank">Contracts</a> 
(in fact, it is really just a consequence of the interaction of the 3 technologies):
stubs that act as parameterized models while complying to the interface contracts.
</p>
        <ul>
          <li>
Code Contracts provide contracts for interfaces. All implementations of that particular
interface will be instrumented with the runtime checks by the rewriter <b>at compile
time</b>. 
</li>
          <li>
Stubs is really just a code generator that provides a minimal implementation of interfaces
and relies on the C# compiler to build the code. Therefore, if a stub implements an
interface with contracts, it will automatically be instrumented by the runtime rewriter
as well. 
</li>
          <li>
Pex choices (i.e. dynamic parameter generation) may be used as the fallback behavior
of stubs. In other words, whenever a stubbed method without user-defined behavior
is called, Pex gets to pick the return value. Since the stub implementation itself
may have been instrumented with contracts, we’ve added special handling code so that <b>post-condition
violation coming from a stub are considered as an assumption</b>. This effectively
forces Pex to generate values that comply with the interface contracts. 
</li>
        </ul>
        <p>
Let’s see how this works with an example. The IFoo interface contains a single ‘GetName’
method. This method has one precondition, i should be positive and one postcondition,
the result is non null. Since interfaces cannot have a method body, we use a ‘buddy’
class to express those contracts and bind both classes using the [ContractClass] and
[ContractClassFor] attributes:
</p>
        <p>
          <a href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles4A3CCC8\image%5b15%5d.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsasParameterizedModeldwithCodeContra_D4E6/clip_image002_92a5f4fd-8fb6-46ca-9bc9-1f3638fa9af8.gif" width="557" height="291" />
          </a>
        </p>
        <p>
We then turn on runtime rewriting for both the project under test and the test project
(Project properties –&gt; Code Contracts –&gt; Runtime checks). As a result, the stub
of IFoo automatically gets instrumented with the contracts. We can clearly see that
from the generated code of GetName in Reflector below:
</p>
        <p>
          <a href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles4A3CCC8\image%5b19%5d.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsasParameterizedModeldwithCodeContra_D4E6/clip_image004_e18deaf5-0c62-467a-9d37-14ad9817b8b6.gif" width="572" height="278" />
          </a>
        </p>
        <p>
The last step is to write a test for IFoo. In this case, we write a parameterized
unit test that takes an IFoo instance and an integer, then simply call GetName.
</p>
        <p>
          <a href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles4A3CCC8\image%5b30%5d.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image006" border="0" alt="clip_image006" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsasParameterizedModeldwithCodeContra_D4E6/clip_image006_2e49dd05-8b33-49fa-a84d-e1c2e2a1af1a.gif" width="337" height="150" />
          </a>
        </p>
        <p>
Since the contracts of IFoo.GetName specifies that the result should not be null,
we should not see any assertion violation in this test. Moreover, we should see a
test for the precondition considered as an expected exception:
</p>
        <p>
          <a href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles4A3CCC8\image%5b29%5d.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image008" border="0" alt="clip_image008" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsasParameterizedModeldwithCodeContra_D4E6/clip_image008_5f0984a3-2fca-4b3f-a226-3e724802109d.gif" width="622" height="82" />
          </a>
        </p>
        <p>
Note that all those behaviors rely on extensions to Pex that the wizard automatically
inserted in the PexAssemblyInfo.cs file:
</p>
        <p>
          <a href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles4A3CCC8\image%5b34%5d.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image010" border="0" alt="clip_image010" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsasParameterizedModeldwithCodeContra_D4E6/clip_image010_4b1ce042-a76c-490a-a4a3-90613d0f528d.gif" width="518" height="115" />
          </a>
        </p>
        <p>
where
</p>
        <ul>
          <li>
[PexAssumeContractEnsuresFailureAtStubSurface] filters post-condition violations in
stubs as assumptions, 
</li>
          <li>
[PexChooseAsStubFallbackBehavior] installs Pex choices as the fallback behavior of
stubs, 
</li>
          <li>
[PexStubsPackage] load the stubs package (this is a standard procedure for Pex packages), 
</li>
          <li>
[PexUseStubsFromTestAssembly] specifies to Pex that it should considers stub types
when trying to test interfaces or abstract classes. 
</li>
        </ul>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=bbda23d8-9f56-4ce8-96b1-b222841d2093" />
      </body>
      <title>Stubs as Parameterized Models with Contracts</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,bbda23d8-9f56-4ce8-96b1-b222841d2093.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/JfBYaGYJhlQ/StubsAsParameterizedModelsWithContracts.aspx</link>
      <pubDate>Sat, 02 May 2009 17:19:16 GMT</pubDate>
      <description>&lt;p&gt;
This is a cool new feature that builds on &lt;a href="http://research.microsoft.com/stubs" target="_blank"&gt;Stubs&lt;/a&gt;, &lt;a href="http://research.microsoft.com/pex" target="_blank"&gt;Pex&lt;/a&gt;&amp;#160;
and Code &lt;a href="http://research.microsoft.com/contracts" target="_blank"&gt;Contracts&lt;/a&gt;&amp;#160;
(in fact, it is really just a consequence of the interaction of the 3 technologies):
stubs that act as parameterized models while complying to the interface contracts.
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Code Contracts provide contracts for interfaces. All implementations of that particular
interface will be instrumented with the runtime checks by the rewriter &lt;b&gt;at compile
time&lt;/b&gt;. 
&lt;/li&gt;
&lt;li&gt;
Stubs is really just a code generator that provides a minimal implementation of interfaces
and relies on the C# compiler to build the code. Therefore, if a stub implements an
interface with contracts, it will automatically be instrumented by the runtime rewriter
as well. 
&lt;/li&gt;
&lt;li&gt;
Pex choices (i.e. dynamic parameter generation) may be used as the fallback behavior
of stubs. In other words, whenever a stubbed method without user-defined behavior
is called, Pex gets to pick the return value. Since the stub implementation itself
may have been instrumented with contracts, we’ve added special handling code so that &lt;b&gt;post-condition
violation coming from a stub are considered as an assumption&lt;/b&gt;. This effectively
forces Pex to generate values that comply with the interface contracts. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Let’s see how this works with an example. The IFoo interface contains a single ‘GetName’
method. This method has one precondition, i should be positive and one postcondition,
the result is non null. Since interfaces cannot have a method body, we use a ‘buddy’
class to express those contracts and bind both classes using the [ContractClass] and
[ContractClassFor] attributes:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles4A3CCC8\image%5b15%5d.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsasParameterizedModeldwithCodeContra_D4E6/clip_image002_92a5f4fd-8fb6-46ca-9bc9-1f3638fa9af8.gif" width="557" height="291" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
We then turn on runtime rewriting for both the project under test and the test project
(Project properties –&amp;gt; Code Contracts –&amp;gt; Runtime checks). As a result, the stub
of IFoo automatically gets instrumented with the contracts. We can clearly see that
from the generated code of GetName in Reflector below:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles4A3CCC8\image%5b19%5d.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsasParameterizedModeldwithCodeContra_D4E6/clip_image004_e18deaf5-0c62-467a-9d37-14ad9817b8b6.gif" width="572" height="278" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
The last step is to write a test for IFoo. In this case, we write a parameterized
unit test that takes an IFoo instance and an integer, then simply call GetName.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles4A3CCC8\image%5b30%5d.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image006" border="0" alt="clip_image006" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsasParameterizedModeldwithCodeContra_D4E6/clip_image006_2e49dd05-8b33-49fa-a84d-e1c2e2a1af1a.gif" width="337" height="150" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Since the contracts of IFoo.GetName specifies that the result should not be null,
we should not see any assertion violation in this test. Moreover, we should see a
test for the precondition considered as an expected exception:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles4A3CCC8\image%5b29%5d.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image008" border="0" alt="clip_image008" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsasParameterizedModeldwithCodeContra_D4E6/clip_image008_5f0984a3-2fca-4b3f-a226-3e724802109d.gif" width="622" height="82" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Note that all those behaviors rely on extensions to Pex that the wizard automatically
inserted in the PexAssemblyInfo.cs file:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles4A3CCC8\image%5b34%5d.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image010" border="0" alt="clip_image010" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsasParameterizedModeldwithCodeContra_D4E6/clip_image010_4b1ce042-a76c-490a-a4a3-90613d0f528d.gif" width="518" height="115" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
where
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
[PexAssumeContractEnsuresFailureAtStubSurface] filters post-condition violations in
stubs as assumptions, 
&lt;/li&gt;
&lt;li&gt;
[PexChooseAsStubFallbackBehavior] installs Pex choices as the fallback behavior of
stubs, 
&lt;/li&gt;
&lt;li&gt;
[PexStubsPackage] load the stubs package (this is a standard procedure for Pex packages), 
&lt;/li&gt;
&lt;li&gt;
[PexUseStubsFromTestAssembly] specifies to Pex that it should considers stub types
when trying to test interfaces or abstract classes. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=bbda23d8-9f56-4ce8-96b1-b222841d2093" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,bbda23d8-9f56-4ce8-96b1-b222841d2093.aspx</comments>
      <category>Code Contracts</category>
      <category>Pex</category>
      <category>Stubs</category>
      <category>Testing</category>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/05/02/StubsAsParameterizedModelsWithContracts.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=18226b58-0d8f-484e-a07d-12f3ebae8c1e</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,18226b58-0d8f-484e-a07d-12f3ebae8c1e.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,18226b58-0d8f-484e-a07d-12f3ebae8c1e.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=18226b58-0d8f-484e-a07d-12f3ebae8c1e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We just made a <a href="http://research.microsoft.com/pex/downloads.aspx">quick release</a> to
fix another installer issue related to missing packages. Along the way, we’ve added
an <strong>Exploration Tree View</strong> and <strong>Partial Stubs</strong> support.
</p>
        <p>
          <strong>Exploration Tree View</strong>
        </p>
        <p>
The exploration tree view displays the list of explorations to be executed, running
and finished. It serves as a progress indicator but also as a smooth result explorer.
When browsing through the tree, <a href="http://research.microsoft.com/pex" target="_blank">Pex</a> will
synchronize the exploration result view and the tree view.
</p>
        <p>
The tree view populates each namespace with the fixture types and exploration methods,
and provide a visual feedback on the progress of Pex.
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.12.404ExplorationTreeViewPartialSt_D1CB/image_4.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.12.404ExplorationTreeViewPartialSt_D1CB/image_thumb_1.png" width="390" height="363" />
          </a>
        </p>
        <p>
When you browse through the exploration and generated test nodes, Pex automatically
synchronizes the exploration result display. This makes it really easy to start from
an high-level view of the failures and drill into a particular generated test, with
stack trace and parameter table.
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.12.404ExplorationTreeViewPartialSt_D1CB/image_2.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.12.404ExplorationTreeViewPartialSt_D1CB/image_thumb.png" width="604" height="212" />
          </a>
        </p>
        <p>
          <strong>
          </strong>
        </p>
        <p>
          <strong>Partial Stubs</strong>
        </p>
        <p>
Stubs lets you call the base class implementation of methods as a fallback behavior.
This functionality is commonly referred as <a href="http://ayende.com/Wiki/Default.aspx?Page=Rhino+Mocks+Partial+Mocks">Partial
Mocks</a> or Partial Stubs and is useful to test abstract classes in isolation. Stubs
inheriting from classes have a “CallBase” property that can turn this mode on and
off.
</p>
        <p>
Let see this with the <a href="http://ayende.com/Wiki/Default.aspx?Page=Rhino+Mocks+Partial+Mocks">RhinoMocks
example on partial mocks</a>. Given an abstract ProcessorBase class,
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.12.404ExplorationTreeViewPartialSt_D1CB/image_10.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.12.404ExplorationTreeViewPartialSt_D1CB/image_thumb_4.png" width="337" height="207" />
          </a>
        </p>
        <p>
we write a test for the Inc method. To do so, we provide a stub implementation of
Add that simply increment a counter.
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.12.404ExplorationTreeViewPartialSt_D1CB/image_8.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.12.404ExplorationTreeViewPartialSt_D1CB/image_thumb_3.png" width="558" height="210" />
          </a>
        </p>
        <p>
          <strong>Miscellaneous</strong>
        </p>
        <ul>
          <li>
PexAssume/PexAssert.EnumIsDefine checks that a particular value is defined in an enum. 
</li>
          <li>
Missing OpenMP files in the installer break Pex.</li>
        </ul>
        <p>
          <strong>
          </strong>
        </p>
        <p>
          <strong>Poll:</strong> should we skip 0.13 and go straight for 0.14? :)
</p>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=18226b58-0d8f-484e-a07d-12f3ebae8c1e" />
      </body>
      <title>Pex 0.12.40430.3 : Exploration Tree View, Partial Stubs…</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,18226b58-0d8f-484e-a07d-12f3ebae8c1e.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/GA6q4V-3cCE/Pex012404303ExplorationTreeViewPartialStubs.aspx</link>
      <pubDate>Fri, 01 May 2009 20:28:25 GMT</pubDate>
      <description>&lt;p&gt;
We just made a &lt;a href="http://research.microsoft.com/pex/downloads.aspx"&gt;quick release&lt;/a&gt; to
fix another installer issue related to missing packages. Along the way, we’ve added
an &lt;strong&gt;Exploration Tree View&lt;/strong&gt; and &lt;strong&gt;Partial Stubs&lt;/strong&gt; support.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Exploration Tree View&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
The exploration tree view displays the list of explorations to be executed, running
and finished. It serves as a progress indicator but also as a smooth result explorer.
When browsing through the tree, &lt;a href="http://research.microsoft.com/pex" target="_blank"&gt;Pex&lt;/a&gt; will
synchronize the exploration result view and the tree view.
&lt;/p&gt;
&lt;p&gt;
The tree view populates each namespace with the fixture types and exploration methods,
and provide a visual feedback on the progress of Pex.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.12.404ExplorationTreeViewPartialSt_D1CB/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.12.404ExplorationTreeViewPartialSt_D1CB/image_thumb_1.png" width="390" height="363" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
When you browse through the exploration and generated test nodes, Pex automatically
synchronizes the exploration result display. This makes it really easy to start from
an high-level view of the failures and drill into a particular generated test, with
stack trace and parameter table.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.12.404ExplorationTreeViewPartialSt_D1CB/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.12.404ExplorationTreeViewPartialSt_D1CB/image_thumb.png" width="604" height="212" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Partial Stubs&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Stubs lets you call the base class implementation of methods as a fallback behavior.
This functionality is commonly referred as &lt;a href="http://ayende.com/Wiki/Default.aspx?Page=Rhino+Mocks+Partial+Mocks"&gt;Partial
Mocks&lt;/a&gt; or Partial Stubs and is useful to test abstract classes in isolation. Stubs
inheriting from classes have a “CallBase” property that can turn this mode on and
off.
&lt;/p&gt;
&lt;p&gt;
Let see this with the &lt;a href="http://ayende.com/Wiki/Default.aspx?Page=Rhino+Mocks+Partial+Mocks"&gt;RhinoMocks
example on partial mocks&lt;/a&gt;. Given an abstract ProcessorBase class,
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.12.404ExplorationTreeViewPartialSt_D1CB/image_10.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.12.404ExplorationTreeViewPartialSt_D1CB/image_thumb_4.png" width="337" height="207" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
we write a test for the Inc method. To do so, we provide a stub implementation of
Add that simply increment a counter.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.12.404ExplorationTreeViewPartialSt_D1CB/image_8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pex0.12.404ExplorationTreeViewPartialSt_D1CB/image_thumb_3.png" width="558" height="210" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Miscellaneous&lt;/strong&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
PexAssume/PexAssert.EnumIsDefine checks that a particular value is defined in an enum. 
&lt;/li&gt;
&lt;li&gt;
Missing OpenMP files in the installer break Pex.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;strong&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Poll:&lt;/strong&gt; should we skip 0.13 and go straight for 0.14? :)
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=18226b58-0d8f-484e-a07d-12f3ebae8c1e" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,18226b58-0d8f-484e-a07d-12f3ebae8c1e.aspx</comments>
      <category>Pex</category>
      <category>RiSE</category>
      <category>Stubs</category>
      <category>Testing</category>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/05/01/Pex012404303ExplorationTreeViewPartialStubs.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=9997ca8f-c91a-4581-839f-459e8dc06dc0</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,9997ca8f-c91a-4581-839f-459e8dc06dc0.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,9997ca8f-c91a-4581-839f-459e8dc06dc0.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=9997ca8f-c91a-4581-839f-459e8dc06dc0</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I recorded a <a href="http://channel9.msdn.com/posts/Peli/The-Synergy-of-Code-Contracts-and-Pex/" target="_blank">Channel9
video</a> last week with <a href="http://research.microsoft.com/~maf" target="_blank">Manuel
Fahndrich</a> on the interaction of Code <a href="http://research.microsoft.com/contracts" target="_blank">Contracts</a> and <a href="http://research.microsoft.com/pex" target="_blank">Pex</a>.
The demo gives a glimpse at the nice interaction between Contracts (design by contracts)
and Pex (automated white box).
</p>
        <p>
Code Contracts gives you a great way to specify what your code is supposed to do.
These contracts can be leverage for documentation, static checkers but also – tada
– by Pex! Contracts can also be turned into runtime checks which Pex will try to explore.
Pex will try to cover the post conditions, assertions or in other words, find inputs
that violates of your contracts etc… By adding contracts to your code, you give Pex
a ‘direction’ to search for (and a test oracle).
</p>
        <p>
          <a href="http://channel9.msdn.com/posts/Peli/The-Synergy-of-Code-Contracts-and-Pex/">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/DesignByContractsmeetsAutomatedWhiteboxT_1261F/image_3.png" width="328" height="247" />
          </a> 
</p>
        <p>
Drop me a note if you want more of those movies.
</p>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=9997ca8f-c91a-4581-839f-459e8dc06dc0" />
      </body>
      <title>Design By Contracts meets Automated White box Testing</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,9997ca8f-c91a-4581-839f-459e8dc06dc0.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/aclBLBqfxKg/DesignByContractsMeetsAutomatedWhiteBoxTesting.aspx</link>
      <pubDate>Sun, 26 Apr 2009 04:09:57 GMT</pubDate>
      <description>&lt;p&gt;
I recorded a &lt;a href="http://channel9.msdn.com/posts/Peli/The-Synergy-of-Code-Contracts-and-Pex/" target="_blank"&gt;Channel9
video&lt;/a&gt; last week with &lt;a href="http://research.microsoft.com/~maf" target="_blank"&gt;Manuel
Fahndrich&lt;/a&gt; on the interaction of Code &lt;a href="http://research.microsoft.com/contracts" target="_blank"&gt;Contracts&lt;/a&gt; and &lt;a href="http://research.microsoft.com/pex" target="_blank"&gt;Pex&lt;/a&gt;.
The demo gives a glimpse at the nice interaction between Contracts (design by contracts)
and Pex (automated white box).
&lt;/p&gt;
&lt;p&gt;
Code Contracts gives you a great way to specify what your code is supposed to do.
These contracts can be leverage for documentation, static checkers but also – tada
– by Pex! Contracts can also be turned into runtime checks which Pex will try to explore.
Pex will try to cover the post conditions, assertions or in other words, find inputs
that violates of your contracts etc… By adding contracts to your code, you give Pex
a ‘direction’ to search for (and a test oracle).
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://channel9.msdn.com/posts/Peli/The-Synergy-of-Code-Contracts-and-Pex/"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/DesignByContractsmeetsAutomatedWhiteboxT_1261F/image_3.png" width="328" height="247" /&gt;&lt;/a&gt;&amp;#160;
&lt;/p&gt;
&lt;p&gt;
Drop me a note if you want more of those movies.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=9997ca8f-c91a-4581-839f-459e8dc06dc0" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,9997ca8f-c91a-4581-839f-459e8dc06dc0.aspx</comments>
      <category>Code Contracts</category>
      <category>Pex</category>
      <category>Testing</category>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/04/26/DesignByContractsMeetsAutomatedWhiteBoxTesting.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=7c5d5cdd-7ebc-4a3d-8fb1-e84b187343b2</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,7c5d5cdd-7ebc-4a3d-8fb1-e84b187343b2.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,7c5d5cdd-7ebc-4a3d-8fb1-e84b187343b2.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=7c5d5cdd-7ebc-4a3d-8fb1-e84b187343b2</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <em>Update: Andrew Kazyrevich does the final performance analysis <a href="http://codevanced.net/post/The-Shark-Fin-Pex.aspx">on
his blog</a>. 
<br />
Update II: Stubs v0.12.40430.3 has Partial Stubs support. </em>
        </p>
        <p>
          <a href="http://research.microsoft.com/stubs" target="_blank">Stubs</a> is a lightweight
stub framework that is entirely based on delegates. We designed it so that it brings
as little overhead as possible, and as a side effect, is very effective with <a href="http://research.microsoft.com/pex" target="_blank">Pex</a>.
In this post, we’ll see how Stubs ‘look’ with respect to other frameworks.
</p>
        <p>
          <strong>Mocking-framework-compare</strong>
        </p>
        <p>
          <a href="http://codevanced.net/" target="_blank">Andrew Kazyrevich</a> started a project, <a href="http://code.google.com/p/mocking-frameworks-compare/" target="_blank">mocking-framework-compare</a>,
back in February that compared Moq, Rhino, NMock2 and Isolator. This is project compares
various ‘mocking scenarios’ across all those frameworks. I added Stubs to the mix
today (go <a href="http://code.google.com/p/mocking-frameworks-compare/source/detail?r=56" target="_blank">check
it out</a>).
</p>
        <p>
          <strong>What’s a stub in Stubs anyway?</strong>
        </p>
        <p>
Before we dig in, let’s recap how stubs look like when you use Stubs. Stubs uses delegate
to ‘hook’ behavior to interface members.<strong />For every stubbed interface
and class, code is generated at a compile time: One stub class per interface and class.
For each stubbed method, the stub class contains a field. The field has a delegate
type matching the stubbed method. As a user, you can simply attach delegates (or lambdas)
to the delegate fields to assign<strong>*any*</strong> behavior to each member. If
no user delegate is set, Stubs calls into a fallback behavior, i.e. throw or return
the default value. 
</p>
        <p>
Let’s take one of the examples of mocking-framework-compare. The little snippet below
‘stubs’ the TouchIron() method (which is implemented explicitly) by attaching a lambda
to the TouchIron field.
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsComparisonwithothermockingframework_1415A/image_2.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsComparisonwithothermockingframework_1415A/image_thumb.png" width="324" height="133" />
          </a>
        </p>
        <p>
SIHand is the stub type of the IHand interface, it was generated at compile time by
the Stubs framework. Its implementation looks more or less like this:
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsComparisonwithothermockingframework_1415A/image_4.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsComparisonwithothermockingframework_1415A/image_thumb_1.png" width="504" height="289" />
          </a>
        </p>
        <p>
The TouchIron methods really shows the main idea behind stubs: delegates are all we
need to move behavior around.
</p>
        <p>
          <strong>Stubs: relying on the language rather than an API</strong>
        </p>
        <p>
One of the differences of Stubs with other mock frameworks is that Stubs does not
have any API: delegates, lambdas, closures are all features of the programming language,
while assertions are part of the test framework. This is quite obvious when we compare
the BrainTest <a href="http://code.google.com/p/mocking-frameworks-compare/source/browse/trunk/Tests/CS/MoqTests/BrainTests.cs" target="_blank">using
Moq</a> and <a href="http://code.google.com/p/mocking-frameworks-compare/source/browse/trunk/Tests/CS/StubsTests/BrainTests.cs" target="_blank">using
Stubs</a>. In this test, we need to ensure that the brain coordinates the hand and
the mouth so that when a hot iron is touched by the hand, the mouth yells.
</p>
        <ul>
          <li>
Moq: we set up the hand to throw a burn exception when touched with a hot iron and
verify that the mouth yelled. 
</li>
        </ul>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsComparisonwithothermockingframework_1415A/image_6.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsComparisonwithothermockingframework_1415A/image_thumb_2.png" width="612" height="172" />
          </a>
        </p>
        <p>
Moq, as Rhino or Isolate, make smart use of expression trees and/or Reflection.Emit
to define the mock behavior. The expectation and behavior are set through nice and
fluent APIs which really make the developer’s life’s easier.
</p>
        <ul>
          <li>
Stubs: same scenario, we attach a lambda that throws if iron is hot and use a local
to verify that Yell is called (this local is pushed to the heap by the compiler). 
</li>
        </ul>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsComparisonwithothermockingframework_1415A/image_8.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsComparisonwithothermockingframework_1415A/image_thumb_3.png" width="402" height="316" />
          </a> 
</p>
        <p>
Stubs does not have any API. It relies on lambdas (to define new behaviors), closures
(to track side effects) which are given for free by the C# 3.0 language.
</p>
        <p>
          <strong>Performance numbers</strong>
        </p>
        <p>
Does performance matter when it comes to mocking? It’s not really the question we
are trying to answer here. We’re just looking at the benchmark results from the mocking-framework-compare
project. When looking at the results, you’ll notice that Stubs may be 100x to 1000x
faster than other frameworks. This is no surprise since stubs boil down to a virtual
method call, while other frameworks do much more work (in fact we expected worse numbers).
</p>
        <blockquote>
          <p>
Data units of msec resolution = 0.394937 usec 
</p>
          <p>
Mocking methods. 
<br />
Moq      : 100 repeats:  37.471 +- 12%   msec 
<br />
Rhino    : 100 repeats:  38.030 +- 7%    msec 
<br />
NMock2   : 100 repeats:  24.035 +- 4%    msec 
<br /><strong>Stubs    : 100 repeats:   0.115 +- 8%   
msec </strong></p>
          <p>
Mocking events. 
<br />
Moq      : 100 repeats:  86.913 +- 7%   
msec 
<br />
Rhino    : 100 repeats:  61.142 +- 6%    msec 
<br />
NMock2   : 100 repeats:  27.378 +- 6%    msec 
<br /><strong>Stubs    : 100 repeats:   0.071 +- 6%   
msec </strong></p>
          <p>
Mocking properties. 
<br />
Moq      : 100 repeats:  82.434 +- 6%   
msec 
<br />
Rhino    : 100 repeats:  47.471 +- 5%    msec 
<br />
NMock2   : 100 repeats:  11.334 +- 10%   msec 
<br /><strong>Stubs    : 100 repeats:   0.042 +- 15%  
msec </strong></p>
          <p>
Mocking method arguments. 
<br />
Moq      : 100 repeats: 142.668 +- 4%    msec 
<br />
Rhino    : 100 repeats:  45.118 +- 5%    msec 
<br />
NMock2   : 100 repeats:  22.344 +- 7%    msec 
<br /><strong>Stubs    : 100 repeats:   0.078 +- 4%   
msec </strong></p>
          <p>
Partial mocks. 
<br />
Moq      : 100 repeats: 117.581 +- 5%    msec 
<br />
Rhino    : 100 repeats:  58.827 +- 6%    msec 
<br /><strong>Stubs : 100 repeats:   0.054 +- 6%    msec </strong></p>
          <p>
Recursive mocks. 
<br />
Moq      : 100 repeats:  92.482 +- 4%   
msec 
<br />
Rhino    : 100 repeats:  40.921 +- 3%    msec 
<br /><strong>Stubs    : 100 repeats:   0.493 +- 18%  
msec 
<br /></strong>Press any key to continue . . .
</p>
          <p>
          </p>
          <p>
          </p>
        </blockquote>
        <strong>
        </strong>
        <p>
          <strong>Stubs limitations</strong>
        </p>
        <p>
There are many areas where the Stubs fall short or simply don’t support it. Currently,
Stubs are only emitted for C# and <a href="http://ayende.com/Wiki/Default.aspx?Page=Rhino+Mocks+Partial+Mocks" target="_blank">partial
mocks</a> will be supported in the next version.
</p>
        <p>
          <strong>Getting started with Stubs</strong>
        </p>
        <p>
Stubs comes with the <a href="http://research.microsoft.com/pex/downloads.aspx" target="_blank">Pex
installer</a>. If you’re interested on using it, check out the <a href="http://research.microsoft.com/en-us/projects/stubs/gettingstarted.aspx" target="_blank">getting
started page</a> on the Stubs project page where you can also download the full Stubs
primer.
</p>
        <p>
Cheers, Peli
</p>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=7c5d5cdd-7ebc-4a3d-8fb1-e84b187343b2" />
      </body>
      <title>Stubs: Comparison with other mocking frameworks</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,7c5d5cdd-7ebc-4a3d-8fb1-e84b187343b2.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/d_bI1dic4_o/StubsComparisonWithOtherMockingFrameworks.aspx</link>
      <pubDate>Thu, 23 Apr 2009 04:58:03 GMT</pubDate>
      <description>&lt;p&gt;
&lt;em&gt;Update: Andrew Kazyrevich does the final performance analysis &lt;a href="http://codevanced.net/post/The-Shark-Fin-Pex.aspx"&gt;on
his blog&lt;/a&gt;. 
&lt;br /&gt;
Update II: Stubs v0.12.40430.3 has Partial Stubs support. &lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://research.microsoft.com/stubs" target="_blank"&gt;Stubs&lt;/a&gt; is a lightweight
stub framework that is entirely based on delegates. We designed it so that it brings
as little overhead as possible, and as a side effect, is very effective with &lt;a href="http://research.microsoft.com/pex" target="_blank"&gt;Pex&lt;/a&gt;.
In this post, we’ll see how Stubs ‘look’ with respect to other frameworks.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Mocking-framework-compare&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://codevanced.net/" target="_blank"&gt;Andrew Kazyrevich&lt;/a&gt; started a project, &lt;a href="http://code.google.com/p/mocking-frameworks-compare/" target="_blank"&gt;mocking-framework-compare&lt;/a&gt;,
back in February that compared Moq, Rhino, NMock2 and Isolator. This is project compares
various ‘mocking scenarios’ across all those frameworks. I added Stubs to the mix
today (go &lt;a href="http://code.google.com/p/mocking-frameworks-compare/source/detail?r=56" target="_blank"&gt;check
it out&lt;/a&gt;).
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;What’s a stub in Stubs anyway?&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Before we dig in, let’s recap how stubs look like when you use Stubs. Stubs uses delegate
to ‘hook’ behavior to interface members.&lt;strong&gt; &lt;/strong&gt;For every stubbed interface
and class, code is generated at a compile time: One stub class per interface and class.
For each stubbed method, the stub class contains a field. The field has a delegate
type matching the stubbed method. As a user, you can simply attach delegates (or lambdas)
to the delegate fields to assign&lt;strong&gt;*any*&lt;/strong&gt; behavior to each member. If
no user delegate is set, Stubs calls into a fallback behavior, i.e. throw or return
the default value. 
&lt;/p&gt;
&lt;p&gt;
Let’s take one of the examples of mocking-framework-compare. The little snippet below
‘stubs’ the TouchIron() method (which is implemented explicitly) by attaching a lambda
to the TouchIron field.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsComparisonwithothermockingframework_1415A/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsComparisonwithothermockingframework_1415A/image_thumb.png" width="324" height="133" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
SIHand is the stub type of the IHand interface, it was generated at compile time by
the Stubs framework. Its implementation looks more or less like this:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsComparisonwithothermockingframework_1415A/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsComparisonwithothermockingframework_1415A/image_thumb_1.png" width="504" height="289" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
The TouchIron methods really shows the main idea behind stubs: delegates are all we
need to move behavior around.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Stubs: relying on the language rather than an API&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
One of the differences of Stubs with other mock frameworks is that Stubs does not
have any API: delegates, lambdas, closures are all features of the programming language,
while assertions are part of the test framework. This is quite obvious when we compare
the BrainTest &lt;a href="http://code.google.com/p/mocking-frameworks-compare/source/browse/trunk/Tests/CS/MoqTests/BrainTests.cs" target="_blank"&gt;using
Moq&lt;/a&gt; and &lt;a href="http://code.google.com/p/mocking-frameworks-compare/source/browse/trunk/Tests/CS/StubsTests/BrainTests.cs" target="_blank"&gt;using
Stubs&lt;/a&gt;. In this test, we need to ensure that the brain coordinates the hand and
the mouth so that when a hot iron is touched by the hand, the mouth yells.
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Moq: we set up the hand to throw a burn exception when touched with a hot iron and
verify that the mouth yelled. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsComparisonwithothermockingframework_1415A/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsComparisonwithothermockingframework_1415A/image_thumb_2.png" width="612" height="172" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Moq, as Rhino or Isolate, make smart use of expression trees and/or Reflection.Emit
to define the mock behavior. The expectation and behavior are set through nice and
fluent APIs which really make the developer’s life’s easier.
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Stubs: same scenario, we attach a lambda that throws if iron is hot and use a local
to verify that Yell is called (this local is pushed to the heap by the compiler). 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsComparisonwithothermockingframework_1415A/image_8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/StubsComparisonwithothermockingframework_1415A/image_thumb_3.png" width="402" height="316" /&gt;&lt;/a&gt;&amp;#160;
&lt;/p&gt;
&lt;p&gt;
Stubs does not have any API. It relies on lambdas (to define new behaviors), closures
(to track side effects) which are given for free by the C# 3.0 language.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Performance numbers&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Does performance matter when it comes to mocking? It’s not really the question we
are trying to answer here. We’re just looking at the benchmark results from the mocking-framework-compare
project. When looking at the results, you’ll notice that Stubs may be 100x to 1000x
faster than other frameworks. This is no surprise since stubs boil down to a virtual
method call, while other frameworks do much more work (in fact we expected worse numbers).
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
Data units of msec resolution = 0.394937 usec 
&lt;/p&gt;
&lt;p&gt;
Mocking methods. 
&lt;br /&gt;
Moq&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; : 100 repeats:&amp;#160; 37.471 +- 12%&amp;#160;&amp;#160; msec 
&lt;br /&gt;
Rhino&amp;#160;&amp;#160;&amp;#160; : 100 repeats:&amp;#160; 38.030 +- 7%&amp;#160;&amp;#160;&amp;#160; msec 
&lt;br /&gt;
NMock2&amp;#160;&amp;#160; : 100 repeats:&amp;#160; 24.035 +- 4%&amp;#160;&amp;#160;&amp;#160; msec 
&lt;br /&gt;
&lt;strong&gt;Stubs&amp;#160;&amp;#160;&amp;#160; : 100 repeats:&amp;#160;&amp;#160; 0.115 +- 8%&amp;#160;&amp;#160;&amp;#160;
msec &lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Mocking events. 
&lt;br /&gt;
Moq&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; : 100 repeats:&amp;#160; 86.913 +- 7%&amp;#160;&amp;#160;&amp;#160;
msec 
&lt;br /&gt;
Rhino&amp;#160;&amp;#160;&amp;#160; : 100 repeats:&amp;#160; 61.142 +- 6%&amp;#160;&amp;#160;&amp;#160; msec 
&lt;br /&gt;
NMock2&amp;#160;&amp;#160; : 100 repeats:&amp;#160; 27.378 +- 6%&amp;#160;&amp;#160;&amp;#160; msec 
&lt;br /&gt;
&lt;strong&gt;Stubs&amp;#160;&amp;#160;&amp;#160; : 100 repeats:&amp;#160;&amp;#160; 0.071 +- 6%&amp;#160;&amp;#160;&amp;#160;
msec &lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Mocking properties. 
&lt;br /&gt;
Moq&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; : 100 repeats:&amp;#160; 82.434 +- 6%&amp;#160;&amp;#160;&amp;#160;
msec 
&lt;br /&gt;
Rhino&amp;#160;&amp;#160;&amp;#160; : 100 repeats:&amp;#160; 47.471 +- 5%&amp;#160;&amp;#160;&amp;#160; msec 
&lt;br /&gt;
NMock2&amp;#160;&amp;#160; : 100 repeats:&amp;#160; 11.334 +- 10%&amp;#160;&amp;#160; msec 
&lt;br /&gt;
&lt;strong&gt;Stubs&amp;#160;&amp;#160;&amp;#160; : 100 repeats:&amp;#160;&amp;#160; 0.042 +- 15%&amp;#160;&amp;#160;
msec &lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Mocking method arguments. 
&lt;br /&gt;
Moq&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; : 100 repeats: 142.668 +- 4%&amp;#160;&amp;#160;&amp;#160; msec 
&lt;br /&gt;
Rhino&amp;#160;&amp;#160;&amp;#160; : 100 repeats:&amp;#160; 45.118 +- 5%&amp;#160;&amp;#160;&amp;#160; msec 
&lt;br /&gt;
NMock2&amp;#160;&amp;#160; : 100 repeats:&amp;#160; 22.344 +- 7%&amp;#160;&amp;#160;&amp;#160; msec 
&lt;br /&gt;
&lt;strong&gt;Stubs&amp;#160;&amp;#160;&amp;#160; : 100 repeats:&amp;#160;&amp;#160; 0.078 +- 4%&amp;#160;&amp;#160;&amp;#160;
msec &lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Partial mocks. 
&lt;br /&gt;
Moq&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; : 100 repeats: 117.581 +- 5%&amp;#160;&amp;#160;&amp;#160; msec 
&lt;br /&gt;
Rhino&amp;#160;&amp;#160;&amp;#160; : 100 repeats:&amp;#160; 58.827 +- 6%&amp;#160;&amp;#160;&amp;#160; msec 
&lt;br /&gt;
&lt;strong&gt;Stubs : 100 repeats:&amp;#160;&amp;#160; 0.054 +- 6%&amp;#160;&amp;#160;&amp;#160; msec &lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Recursive mocks. 
&lt;br /&gt;
Moq&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; : 100 repeats:&amp;#160; 92.482 +- 4%&amp;#160;&amp;#160;&amp;#160;
msec 
&lt;br /&gt;
Rhino&amp;#160;&amp;#160;&amp;#160; : 100 repeats:&amp;#160; 40.921 +- 3%&amp;#160;&amp;#160;&amp;#160; msec 
&lt;br /&gt;
&lt;strong&gt;Stubs&amp;#160;&amp;#160;&amp;#160; : 100 repeats:&amp;#160;&amp;#160; 0.493 +- 18%&amp;#160;&amp;#160;
msec 
&lt;br /&gt;
&lt;/strong&gt;Press any key to continue . . .
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;/blockquote&gt; &lt;strong&gt;&lt;/strong&gt; 
&lt;p&gt;
&lt;strong&gt;Stubs limitations&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
There are many areas where the Stubs fall short or simply don’t support it. Currently,
Stubs are only emitted for C# and &lt;a href="http://ayende.com/Wiki/Default.aspx?Page=Rhino+Mocks+Partial+Mocks" target="_blank"&gt;partial
mocks&lt;/a&gt; will be supported in the next version.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Getting started with Stubs&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Stubs comes with the &lt;a href="http://research.microsoft.com/pex/downloads.aspx" target="_blank"&gt;Pex
installer&lt;/a&gt;. If you’re interested on using it, check out the &lt;a href="http://research.microsoft.com/en-us/projects/stubs/gettingstarted.aspx" target="_blank"&gt;getting
started page&lt;/a&gt; on the Stubs project page where you can also download the full Stubs
primer.
&lt;/p&gt;
&lt;p&gt;
Cheers, Peli
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=7c5d5cdd-7ebc-4a3d-8fb1-e84b187343b2" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,7c5d5cdd-7ebc-4a3d-8fb1-e84b187343b2.aspx</comments>
      <category>Pex</category>
      <category>Stubs</category>
      <category>Testing</category>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/04/23/StubsComparisonWithOtherMockingFrameworks.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=3f0e2745-a604-4772-a81d-bf7d75faa21a</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,3f0e2745-a604-4772-a81d-bf7d75faa21a.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,3f0e2745-a604-4772-a81d-bf7d75faa21a.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=3f0e2745-a604-4772-a81d-bf7d75faa21a</wfw:commentRss>
      <slash:comments>5</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">Nikolai just announced the latest drop
of <a href="http://research.microsoft.com/pex" target="_blank">Pex</a>, 0.11.40421.0.
Get <a href="http://blogs.msdn.com/nikolait/archive/2009/04/21/pex-0-11-released-delegates-exception-trees-and-stubs.aspx" target="_blank">all
the details</a> on his blog.<img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=3f0e2745-a604-4772-a81d-bf7d75faa21a" /></body>
      <title>Pex v0.11.40421.0 : Delegates As Parameters, Exception Tree View, Better Stubs.</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,3f0e2745-a604-4772-a81d-bf7d75faa21a.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/tP9BghEJe_4/PexV011404210DelegatesAsParametersExceptionTreeViewBetterStubs.aspx</link>
      <pubDate>Wed, 22 Apr 2009 00:10:17 GMT</pubDate>
      <description>Nikolai just announced the latest drop of &lt;a href="http://research.microsoft.com/pex" target="_blank"&gt;Pex&lt;/a&gt;,
0.11.40421.0. Get &lt;a href="http://blogs.msdn.com/nikolait/archive/2009/04/21/pex-0-11-released-delegates-exception-trees-and-stubs.aspx" target="_blank"&gt;all
the details&lt;/a&gt; on his blog.&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=3f0e2745-a604-4772-a81d-bf7d75faa21a" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,3f0e2745-a604-4772-a81d-bf7d75faa21a.aspx</comments>
      <category>Pex</category>
      <category>RiSE</category>
      <category>Stubs</category>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/04/22/PexV011404210DelegatesAsParametersExceptionTreeViewBetterStubs.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=613f853f-19ed-4482-af6f-685ed1876096</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,613f853f-19ed-4482-af6f-685ed1876096.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,613f853f-19ed-4482-af6f-685ed1876096.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=613f853f-19ed-4482-af6f-685ed1876096</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
For the last couple of weeks, I given on helping hand to Herman Venter to set up the
open-source-MS-PL-super-cool-Common Compiler Infrastructure (<a href="http://ccimetadata.codeplex.com/" target="_blank">CCI</a>)
project. 
</p>
        <p>
You’ve may have heard and probably used different incarnations of the CCI in the past:
the FxCop introspection engine, <a href="http://research.microsoft.com/en-us/people/mbarnett/ilmerge.aspx" target="_blank">ILMerge</a>, <a href="http://research.microsoft.com/en-us/projects/specsharp/" target="_blank">Spec#</a> or
Code <a href="http://research.microsoft.com/contracts" target="_blank">Contracts</a> use
CCI in same ways. CCI is a set of tools and components that are useful to build compilers:
readers and writers for MSIL and symbol files, and more. With CCI, you can now <em>easily</em> write
your own crazy aspect oriented programming framework, inspect assemblies without reflection
etc…  Just sync the sources, build it, tweak it, etc… It’s all there on <a href="http://ccimetadata.codeplex.com/" target="_blank">codeplex</a> at <a href="http://ccimetadata.codeplex.com">http://ccimetadata.codeplex.com</a>.
</p>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=613f853f-19ed-4482-af6f-685ed1876096" />
      </body>
      <title>Read, morph, tweak, write MSIL with CCI (open source)</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,613f853f-19ed-4482-af6f-685ed1876096.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/rajOheTwCIY/ReadMorphTweakWriteMSILWithCCIOpenSource.aspx</link>
      <pubDate>Thu, 16 Apr 2009 03:51:23 GMT</pubDate>
      <description>&lt;p&gt;
For the last couple of weeks, I given on helping hand to Herman Venter to set up the
open-source-MS-PL-super-cool-Common Compiler Infrastructure (&lt;a href="http://ccimetadata.codeplex.com/" target="_blank"&gt;CCI&lt;/a&gt;)
project. 
&lt;/p&gt;
&lt;p&gt;
You’ve may have heard and probably used different incarnations of the CCI in the past:
the FxCop introspection engine, &lt;a href="http://research.microsoft.com/en-us/people/mbarnett/ilmerge.aspx" target="_blank"&gt;ILMerge&lt;/a&gt;, &lt;a href="http://research.microsoft.com/en-us/projects/specsharp/" target="_blank"&gt;Spec#&lt;/a&gt; or
Code &lt;a href="http://research.microsoft.com/contracts" target="_blank"&gt;Contracts&lt;/a&gt; use
CCI in same ways. CCI is a set of tools and components that are useful to build compilers:
readers and writers for MSIL and symbol files, and more. With CCI, you can now &lt;em&gt;easily&lt;/em&gt; write
your own crazy aspect oriented programming framework, inspect assemblies without reflection
etc…&amp;#160; Just sync the sources, build it, tweak it, etc… It’s all there on &lt;a href="http://ccimetadata.codeplex.com/" target="_blank"&gt;codeplex&lt;/a&gt; at &lt;a href="http://ccimetadata.codeplex.com"&gt;http://ccimetadata.codeplex.com&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=613f853f-19ed-4482-af6f-685ed1876096" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,613f853f-19ed-4482-af6f-685ed1876096.aspx</comments>
      <category>CCI</category>
      <category>Code Contracts</category>
      <category>RiSE</category>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/04/16/ReadMorphTweakWriteMSILWithCCIOpenSource.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=83fde01f-786e-456d-b1c4-c8dd52448e69</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,83fde01f-786e-456d-b1c4-c8dd52448e69.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,83fde01f-786e-456d-b1c4-c8dd52448e69.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=83fde01f-786e-456d-b1c4-c8dd52448e69</wfw:commentRss>
      <slash:comments>12</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <blockquote>
          <p>
            <a href="http://research.microsoft.com/en-us/projects/pex/downloads.aspx" target="_blank">
              <strong>Download
the new version!</strong>
            </a>
          </p>
        </blockquote>
        <p>
Today we’ve released a new release of <a href="http://research.microsoft.com/pex">Pex</a> on
DevLabs and on our academic downloads. This highlights of this release are: <a href="http://www.nunit.org" target="_blank">NUnit</a>, <a href="http://www.mbunit.com/" target="_blank">MbUnit</a> and <a href="http://xunit.codeplex.com/" target="_blank">xUnit.net</a> support
out of the box, <strong>writing <a href="http://research.microsoft.com/pex">parameterized
unit tests</a> in VisualBasic.NET and F#, better <a href="http://research.microsoft.com/contracts">Code
Contracts</a> support</strong>. As always, if we encourage you to send us feedback,
bugs, stories on our forums at <a href="http://social.msdn.microsoft.com/Forums/en-US/pex/threads/">http://social.msdn.microsoft.com/Forums/en-US/pex/threads/</a> .
</p>
        <p>
          <strong>
            <a href="http://www.nunit.org" target="_blank">NUnit</a>, <a href="http://www.mbunit.com" target="_blank">MbUnit</a> and <a href="http://www.codeplex.com/xunit">xUnit.net</a> supported
out of the box</strong>
        </p>
        <p>
Pex now supports MSTest, NUnit, MbUnit and xUnit.net out of the box. Pex will automatically
detect which framework you are using by inspecting the assembly reference list, and
automatically save the generated tests decorated with the correct attributes for that
framework. 
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_22.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_thumb_10.png" width="604" height="351" />
          </a>
        </p>
        <p>
The default test framework can also be specified through the global options (Tools
–&gt; Options –&gt; Pex –&gt; enter the test framework name in TestFramework).
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_16.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_thumb_7.png" width="604" height="257" />
          </a>
        </p>
        <p>
 
</p>
        <p>
          <strong>Writing Parameterized Unit Tests in VisualBasic.NET</strong>
        </p>
        <p>
While the Pex white box analysis engine works at the MSIL level, Pex only emits C#
code for now. In previous releases, this limitation made it impossible to use Pex
parameterized unit tests from non-C# code. In this release, we have worked around
this problem by automatically saving the generated tests in a ‘satellite’ C# project.
</p>
        <p>
Let’s see this with an example. The screenshot below shows a single VisualBasic.NET
test project with a Pex parameterized unit test:
</p>
        <p>
          <a href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles659CA51\image3.png">
            <b>
              <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/clip_image002_0dd1c4a7-6732-42b8-b6fe-76f7499e6a66.gif" width="604" height="237" />
            </b>
          </a>
        </p>
        <p>
We can right-click in the HelloTest.Hello method and select “Run Pex Explorations”:
</p>
        <p>
          <a href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles659CA51\image7.png">
            <b>
              <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/clip_image004_31e0ecca-a518-4ec3-9ad4-3fef0bb58593.gif" width="305" height="91" />
            </b>
          </a>
        </p>
        <p>
At this point, Pex will start exploring the test in the background as usual. This
is where the new support comes in: When a generated test comes back to Visual Studio,
Pex will save it in a separate C# project automatically (after asking you where to
drop the new project):
</p>
        <p>
          <a href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles659CA51\image19.png">
            <b>
              <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image006" border="0" alt="clip_image006" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/clip_image006_324456a0-a756-4cfe-b9cb-e7eb8a9db8a0.gif" width="604" height="391" />
            </b>
          </a>
        </p>
        <p>
The generated tests are now ready to be run just as any other unit tests!
</p>
        <p>
          <strong>Writing Parameterized Unit Tests from F#</strong>
        </p>
        <p>
Similarly to VisualBasic.NET, we’ve made improvements in our infrastructure to enable
writing parameterized unit tests in <strong>F#</strong>. Let’s see this with a familiar
example. We have a single F# library that has xUnit.net unit tests and reference Microsoft.Pex.Framework
(project Library2 below). In that project, we add a parameterized unit test (hello_test):
</p>
        <p>
          <a href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles659CA51\image32%5b1%5d.png">
            <b>
              <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image008" border="0" alt="clip_image008" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/clip_image008_709d95c3-12c4-4805-b549-2982d5341032.gif" width="604" height="235" />
            </b>
          </a>
        </p>
        <p>
We can right-click on the <strong>test method name</strong> and Pex will start the
exploration of that test in the background. Because of the limitations of the F# project
system, you <strong>absolutely</strong> need to right-click on the<strong> method
name</strong> in F# if you want contextual test selection to work. Because the project
is already referencing xunit.dll, Pex will also automatically detect that you are
using xUnit.net and use that framework. When the first test case comes back to VisualStudio,
Pex saves it in a separate C# project:
</p>
        <p>
          <a href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles659CA51\image39.png">
            <b>
              <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image010" border="0" alt="clip_image010" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/clip_image010_69f5c0e9-4c03-4251-a79a-38c7ffbb3a19.gif" width="604" height="341" />
            </b>
          </a>
        </p>
        <p>
The tests are saved in the generated test project and ready to be run by your favorite
test runner!
</p>
        <p>
          <strong>PexObserve: Observing values, Asserting values</strong>
        </p>
        <p>
We’ve completely re-factored the way values can be logged on the table or saved as
assertions in the generated tests. The following example shows various ways to log
and assert values:
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_8.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_thumb_3.png" width="451" height="228" />
          </a>
        </p>
        <p>
In the Observe method, we use the return value and out parameter output to automatically
log and assert those values. Additionally, we add “view input” on the fly to the parameter
table through the ValueForViewing method, and we add “check input” to be asserted
through the ValueAtEndOfTest method. After running Pex, we get the following results:
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_10.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_thumb_4.png" width="373" height="63" />
          </a>
        </p>
        <p>
As expected, input, ‘view input’, output and result show up in the parameter table.
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_12.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_thumb_5.png" width="599" height="266" />
          </a>
        </p>
        <p>
In the generated test, we see assertions for the return value, out parameters and
other values passed through the ValueAtEndOfTest method.
</p>
        <p>
          <strong>
            <a href="http://research.microsoft.com/contracts">Code Contracts</a> : Reproducible
generated tests</strong>
        </p>
        <p>
When Pex generates a unit test that relied on a runtime contract, Pex also adds a
check to the unit test which validates that the contracts have been injected into
the code by the contracts rewriter. If the code is not rewritten when re-executing
the unit test, it is marked as inconclusive. You will appreciate this behavior when
you run your unit tests both in Release and in Debug builds, which usually differ
in how contracts get injected.
</p>
        <p>
          <a href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles659CA51\image43.png">
            <b>
              <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image012" border="0" alt="clip_image012" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/clip_image012_32c70deb-1184-48c7-a1cd-16e1c19559d3.gif" width="604" height="177" />
            </b>
          </a>
        </p>
        <p>
          <strong>Code Contracts:  Automatic filtering of the contract violations</strong>
        </p>
        <p>
When Pex generates a test that violates a Code Contract pre-condition (i.e. Contract.Requires),
there are basically two scenarios: the precondition was on top of the stack and should
be considered as an expected exception; or it is a nested exception and should be
considered as a bug. Pex provides a default exception filtering that implements this
behavior.
</p>
        <p>
          <strong>
            <a href="http://research.microsoft.com/stubs" target="_blank">Stubs</a>: simplified
syntax</strong>
        </p>
        <p>
We’ve considerably simplified the syntax of stubs by removing the ‘this’ parameter
from the stub delegate definition. Let’s illustrate this with a test that stubs the
‘ReadAllText’ method of a fictitious ‘IFileSystem’ interface.  
</p>
        <p>
          <img src="http://research.microsoft.com/en-us/projects/stubs/stubexample.png" />
        </p>
        <p>
          <strong>
            <a href="http://research.microsoft.com/stubs" target="_blank">Stubs</a>: generic
methods</strong>
        </p>
        <p>
The <a href="http://research.microsoft.com/stubs" target="_blank">Stubs</a> framework
now supports stubbing generic methods by providing particular instantiations of that
method. In the following example, the generic Bar&lt;T&gt; method is stubbed for the
particular Bar&lt;int&gt; instantiation:
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_2.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_thumb.png" width="435" height="119" />
          </a>
        </p>
        <p>
          <strong>Stubs and Pex: Pex will choose the stubs behavior by default</strong>
        </p>
        <p>
We provide a new custom attribute, PexChooseAsStubFallbackBehaviorAttribute, that
hooks Pex choices to the Stub fallback behavior. To illustrate what this means, let’s
modify slightly the example above by removing the stub of ReadAllText:
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_4.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_thumb_1.png" width="455" height="216" />
          </a>
        </p>
        <p>
If this test was to be run without the PexChooseAsStubFallbackBehavior attribute,
it would throw a StubNotImplementedException. However, with the PexChooseAsStubFallbackBehavior
attribute, the fallback behavior calls into PexChoose to ask Pex for a new string.
In this example in particular, on each call to ReadAllText, Pex will generate a new
string for the result. You can see this string as a new parameter to the parameterized
unit test. Therefore, when we run this test under Pex, we see different behavior happening,
including the “hello world” file:
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_6.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_thumb_2.png" width="584" height="90" />
          </a>
        </p>
        <p>
Note that all the necessary attributes are added at the assembly level by the Pex
Wizard.
</p>
        <p>
          <strong>Miscellanous bug fixes and improvements</strong>
        </p>
        <ul>
          <li>
[fixed] Dialogs do not render correctly under high DPI 
</li>
          <li>
When a generic parameterized unit tests does not have any generic argument instantiations,
Pex makes a guess for you. 
</li>
          <li>
When a test parameter is an interface or an abstract class, Pex now searches the known
assemblies for implementations and concrete classes. In particular, that means that
Pex will often automatically use the automatically generated Stubs implementations
for interfaces or abstract classes. 
</li>
          <li>
Static parameterized unit tests are supported (if static tests are supported by your
test framework) 
</li>
          <li>
Better solving of decimal and floating point constraints. We will report on the details
later. 
</li>
        </ul>
        <p>
          <strong>Breaking Changes</strong>
        </p>
        <ul>
          <li>
The PexFactoryClassAttribute is no longer needed and has been removed. Now, Pex will
pick up object factory methods marked with the PexFactoryMethodAttribute from any <i>static
class</i> in the test project containing the parameterized unit tests. If the generated
tests are stored in a separate project, that project is not searched. 
</li>
          <li>
The PexStore API has been renamed to PexObserve. 
</li>
          <li>
Pex is compatible with Code Contracts versions strictly newer than v1.1.20309.13.
Unfortunately, v1.1.20309.13 is the currently available version of Code <a href="http://research.microsoft.com/contracts" target="_blank">Contracts</a>.
The Code Contracts team is planning on a release soon. 
</li>
        </ul>
        <p>
 
</p>
        <p>
Happy Pexing!
</p>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=83fde01f-786e-456d-b1c4-c8dd52448e69" />
      </body>
      <title>Pex v0.10.40408.0: NUnit, MbUnit, xUnit.Net, Visual Basic.NET, F# and more…</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,83fde01f-786e-456d-b1c4-c8dd52448e69.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/Hf0E2nXCC8c/PexV010404080NUnitMbUnitXUnitNetVisualBasicNETFAndMore.aspx</link>
      <pubDate>Fri, 10 Apr 2009 19:06:31 GMT</pubDate>
      <description>&lt;blockquote&gt; 
&lt;p&gt;
&lt;a href="http://research.microsoft.com/en-us/projects/pex/downloads.aspx" target="_blank"&gt;&lt;strong&gt;Download
the new version!&lt;/strong&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Today we’ve released a new release of &lt;a href="http://research.microsoft.com/pex"&gt;Pex&lt;/a&gt; on
DevLabs and on our academic downloads. This highlights of this release are: &lt;a href="http://www.nunit.org" target="_blank"&gt;NUnit&lt;/a&gt;, &lt;a href="http://www.mbunit.com/" target="_blank"&gt;MbUnit&lt;/a&gt; and &lt;a href="http://xunit.codeplex.com/" target="_blank"&gt;xUnit.net&lt;/a&gt; support
out of the box, &lt;strong&gt;writing &lt;a href="http://research.microsoft.com/pex"&gt;parameterized
unit tests&lt;/a&gt; in VisualBasic.NET and F#, better &lt;a href="http://research.microsoft.com/contracts"&gt;Code
Contracts&lt;/a&gt; support&lt;/strong&gt;. As always, if we encourage you to send us feedback,
bugs, stories on our forums at &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/pex/threads/"&gt;http://social.msdn.microsoft.com/Forums/en-US/pex/threads/&lt;/a&gt; .
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;a href="http://www.nunit.org" target="_blank"&gt;NUnit&lt;/a&gt;, &lt;a href="http://www.mbunit.com" target="_blank"&gt;MbUnit&lt;/a&gt; and &lt;a href="http://www.codeplex.com/xunit"&gt;xUnit.net&lt;/a&gt; supported
out of the box&lt;/strong&gt; 
&lt;/p&gt;
&lt;p&gt;
Pex now supports MSTest, NUnit, MbUnit and xUnit.net out of the box. Pex will automatically
detect which framework you are using by inspecting the assembly reference list, and
automatically save the generated tests decorated with the correct attributes for that
framework. 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_22.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_thumb_10.png" width="604" height="351" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
The default test framework can also be specified through the global options (Tools
–&amp;gt; Options –&amp;gt; Pex –&amp;gt; enter the test framework name in TestFramework).
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_16.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_thumb_7.png" width="604" height="257" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Writing Parameterized Unit Tests in VisualBasic.NET&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
While the Pex white box analysis engine works at the MSIL level, Pex only emits C#
code for now. In previous releases, this limitation made it impossible to use Pex
parameterized unit tests from non-C# code. In this release, we have worked around
this problem by automatically saving the generated tests in a ‘satellite’ C# project.
&lt;/p&gt;
&lt;p&gt;
Let’s see this with an example. The screenshot below shows a single VisualBasic.NET
test project with a Pex parameterized unit test:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles659CA51\image3.png"&gt;&lt;b&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/clip_image002_0dd1c4a7-6732-42b8-b6fe-76f7499e6a66.gif" width="604" height="237" /&gt;&lt;/b&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
We can right-click in the HelloTest.Hello method and select “Run Pex Explorations”:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles659CA51\image7.png"&gt;&lt;b&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/clip_image004_31e0ecca-a518-4ec3-9ad4-3fef0bb58593.gif" width="305" height="91" /&gt;&lt;/b&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
At this point, Pex will start exploring the test in the background as usual. This
is where the new support comes in: When a generated test comes back to Visual Studio,
Pex will save it in a separate C# project automatically (after asking you where to
drop the new project):
&lt;/p&gt;
&lt;p&gt;
&lt;a href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles659CA51\image19.png"&gt;&lt;b&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image006" border="0" alt="clip_image006" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/clip_image006_324456a0-a756-4cfe-b9cb-e7eb8a9db8a0.gif" width="604" height="391" /&gt;&lt;/b&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
The generated tests are now ready to be run just as any other unit tests!
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Writing Parameterized Unit Tests from F#&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Similarly to VisualBasic.NET, we’ve made improvements in our infrastructure to enable
writing parameterized unit tests in &lt;strong&gt;F#&lt;/strong&gt;. Let’s see this with a familiar
example. We have a single F# library that has xUnit.net unit tests and reference Microsoft.Pex.Framework
(project Library2 below). In that project, we add a parameterized unit test (hello_test):
&lt;/p&gt;
&lt;p&gt;
&lt;a href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles659CA51\image32%5b1%5d.png"&gt;&lt;b&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image008" border="0" alt="clip_image008" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/clip_image008_709d95c3-12c4-4805-b549-2982d5341032.gif" width="604" height="235" /&gt;&lt;/b&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
We can right-click on the &lt;strong&gt;test method name&lt;/strong&gt; and Pex will start the
exploration of that test in the background. Because of the limitations of the F# project
system, you &lt;strong&gt;absolutely&lt;/strong&gt; need to right-click on the&lt;strong&gt; method
name&lt;/strong&gt; in F# if you want contextual test selection to work. Because the project
is already referencing xunit.dll, Pex will also automatically detect that you are
using xUnit.net and use that framework. When the first test case comes back to VisualStudio,
Pex saves it in a separate C# project:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles659CA51\image39.png"&gt;&lt;b&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image010" border="0" alt="clip_image010" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/clip_image010_69f5c0e9-4c03-4251-a79a-38c7ffbb3a19.gif" width="604" height="341" /&gt;&lt;/b&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
The tests are saved in the generated test project and ready to be run by your favorite
test runner!
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;PexObserve: Observing values, Asserting values&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
We’ve completely re-factored the way values can be logged on the table or saved as
assertions in the generated tests. The following example shows various ways to log
and assert values:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_thumb_3.png" width="451" height="228" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
In the Observe method, we use the return value and out parameter output to automatically
log and assert those values. Additionally, we add “view input” on the fly to the parameter
table through the ValueForViewing method, and we add “check input” to be asserted
through the ValueAtEndOfTest method. After running Pex, we get the following results:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_10.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_thumb_4.png" width="373" height="63" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
As expected, input, ‘view input’, output and result show up in the parameter table.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_12.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_thumb_5.png" width="599" height="266" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
In the generated test, we see assertions for the return value, out parameters and
other values passed through the ValueAtEndOfTest method.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;a href="http://research.microsoft.com/contracts"&gt;Code Contracts&lt;/a&gt; : Reproducible
generated tests&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
When Pex generates a unit test that relied on a runtime contract, Pex also adds a
check to the unit test which validates that the contracts have been injected into
the code by the contracts rewriter. If the code is not rewritten when re-executing
the unit test, it is marked as inconclusive. You will appreciate this behavior when
you run your unit tests both in Release and in Debug builds, which usually differ
in how contracts get injected.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="file:///C:\Users\jhalleux\AppData\Local\Temp\WindowsLiveWriter-429641856\supfiles659CA51\image43.png"&gt;&lt;b&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image012" border="0" alt="clip_image012" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/clip_image012_32c70deb-1184-48c7-a1cd-16e1c19559d3.gif" width="604" height="177" /&gt;&lt;/b&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Code Contracts:&amp;#160; Automatic filtering of the contract violations&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
When Pex generates a test that violates a Code Contract pre-condition (i.e. Contract.Requires),
there are basically two scenarios: the precondition was on top of the stack and should
be considered as an expected exception; or it is a nested exception and should be
considered as a bug. Pex provides a default exception filtering that implements this
behavior.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;a href="http://research.microsoft.com/stubs" target="_blank"&gt;Stubs&lt;/a&gt;: simplified
syntax&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
We’ve considerably simplified the syntax of stubs by removing the ‘this’ parameter
from the stub delegate definition. Let’s illustrate this with a test that stubs the
‘ReadAllText’ method of a fictitious ‘IFileSystem’ interface.&amp;#160; 
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://research.microsoft.com/en-us/projects/stubs/stubexample.png" /&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;a href="http://research.microsoft.com/stubs" target="_blank"&gt;Stubs&lt;/a&gt;: generic
methods&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
The &lt;a href="http://research.microsoft.com/stubs" target="_blank"&gt;Stubs&lt;/a&gt; framework
now supports stubbing generic methods by providing particular instantiations of that
method. In the following example, the generic Bar&amp;lt;T&amp;gt; method is stubbed for the
particular Bar&amp;lt;int&amp;gt; instantiation:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_thumb.png" width="435" height="119" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Stubs and Pex: Pex will choose the stubs behavior by default&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
We provide a new custom attribute, PexChooseAsStubFallbackBehaviorAttribute, that
hooks Pex choices to the Stub fallback behavior. To illustrate what this means, let’s
modify slightly the example above by removing the stub of ReadAllText:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_thumb_1.png" width="455" height="216" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
If this test was to be run without the PexChooseAsStubFallbackBehavior attribute,
it would throw a StubNotImplementedException. However, with the PexChooseAsStubFallbackBehavior
attribute, the fallback behavior calls into PexChoose to ask Pex for a new string.
In this example in particular, on each call to ReadAllText, Pex will generate a new
string for the result. You can see this string as a new parameter to the parameterized
unit test. Therefore, when we run this test under Pex, we see different behavior happening,
including the “hello world” file:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/content/binary/WindowsLiveWriter/Pexv0.10.40408.0NUnitMbUnitx.NETFandmore_14623/image_thumb_2.png" width="584" height="90" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Note that all the necessary attributes are added at the assembly level by the Pex
Wizard.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Miscellanous bug fixes and improvements&lt;/strong&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
[fixed] Dialogs do not render correctly under high DPI 
&lt;/li&gt;
&lt;li&gt;
When a generic parameterized unit tests does not have any generic argument instantiations,
Pex makes a guess for you. 
&lt;/li&gt;
&lt;li&gt;
When a test parameter is an interface or an abstract class, Pex now searches the known
assemblies for implementations and concrete classes. In particular, that means that
Pex will often automatically use the automatically generated Stubs implementations
for interfaces or abstract classes. 
&lt;/li&gt;
&lt;li&gt;
Static parameterized unit tests are supported (if static tests are supported by your
test framework) 
&lt;/li&gt;
&lt;li&gt;
Better solving of decimal and floating point constraints. We will report on the details
later. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;strong&gt;Breaking Changes&lt;/strong&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
The PexFactoryClassAttribute is no longer needed and has been removed. Now, Pex will
pick up object factory methods marked with the PexFactoryMethodAttribute from any &lt;i&gt;static
class&lt;/i&gt; in the test project containing the parameterized unit tests. If the generated
tests are stored in a separate project, that project is not searched. 
&lt;/li&gt;
&lt;li&gt;
The PexStore API has been renamed to PexObserve. 
&lt;/li&gt;
&lt;li&gt;
Pex is compatible with Code Contracts versions strictly newer than v1.1.20309.13.
Unfortunately, v1.1.20309.13 is the currently available version of Code &lt;a href="http://research.microsoft.com/contracts" target="_blank"&gt;Contracts&lt;/a&gt;.
The Code Contracts team is planning on a release soon. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
Happy Pexing!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=83fde01f-786e-456d-b1c4-c8dd52448e69" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,83fde01f-786e-456d-b1c4-c8dd52448e69.aspx</comments>
      <category>Code Contracts</category>
      <category>MbUnit</category>
      <category>Pex</category>
      <category>RiSE</category>
      <category>Stubs</category>
      <category>Testing</category>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/04/10/PexV010404080NUnitMbUnitXUnitNetVisualBasicNETFAndMore.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=5a6044a6-c289-44a7-b921-f06e5b7bafb6</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,5a6044a6-c289-44a7-b921-f06e5b7bafb6.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,5a6044a6-c289-44a7-b921-f06e5b7bafb6.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=5a6044a6-c289-44a7-b921-f06e5b7bafb6</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I just released a new version of <strong>QuickGraph for Silverlight</strong> on <a href="http://quickgraph.codeplex.com">http://quickgraph.codeplex.com</a> .
You can grad it to run your favorite graph algorithm in the silverlight browser!
</p>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=5a6044a6-c289-44a7-b921-f06e5b7bafb6" />
      </body>
      <title>QuickGraph for Silverlight (new release)</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,5a6044a6-c289-44a7-b921-f06e5b7bafb6.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/ZpEhelpXjwo/QuickGraphForSilverlightNewRelease.aspx</link>
      <pubDate>Thu, 09 Apr 2009 12:29:58 GMT</pubDate>
      <description>&lt;p&gt;
I just released a new version of &lt;strong&gt;QuickGraph for Silverlight&lt;/strong&gt; on &lt;a href="http://quickgraph.codeplex.com"&gt;http://quickgraph.codeplex.com&lt;/a&gt; .
You can grad it to run your favorite graph algorithm in the silverlight browser!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=5a6044a6-c289-44a7-b921-f06e5b7bafb6" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,5a6044a6-c289-44a7-b921-f06e5b7bafb6.aspx</comments>
      <category>QuickGraph</category>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/04/09/QuickGraphForSilverlightNewRelease.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=f6460df9-7923-4374-968b-480448f73990</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,f6460df9-7923-4374-968b-480448f73990.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,f6460df9-7923-4374-968b-480448f73990.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=f6460df9-7923-4374-968b-480448f73990</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The videos of TechDays are up:
</p>
        <ul>
          <li>
            <a title="TOOL302 Code Contracts, Pex and CHESS- 3 Tools, One Talk (englanninkielinen)" href="http://seminaarit.codezone.fi/video/techdays2009/pe-208-2/">TOOL302
Code Contracts, Pex and CHESS- 3 Tools, One Talk (englanninkielinen)</a>
          </li>
          <li>
            <a title="TOOL404 Pex – Automated White Box Testing for .NET (englanninkielinen)" href="http://seminaarit.codezone.fi/video/techdays2009/pe-208-4/">TOOL404
Pex – Automated White Box Testing for .NET (englanninkielinen)</a>
          </li>
        </ul>
        <p>
While attending TechDays Finland in Helsinki, I had the opportunity (thanks Vesa)
to take a swim in the baltic <strong>frozen</strong> sea along with fellow Microsoftie <a href="http://www.mostlylucid.net/" target="_blank">Scott
Galloway</a> (i’ll spare you the video of the actual bath).
</p>
        <p>
Great way to dust off the remaining of jetlag.
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/images/TechDaysBalticSeaSwimming_8120/P3060024.jpg">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="P3060024" border="0" alt="P3060024" src="http://blog.dotnetwiki.org/images/TechDaysBalticSeaSwimming_8120/P3060024_thumb.jpg" width="644" height="484" />
          </a>
        </p>
        <p>
ps: Yes we are standing on the sea.
</p>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=f6460df9-7923-4374-968b-480448f73990" />
      </body>
      <title>TechDays Videos and Baltic Sea Swimming</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,f6460df9-7923-4374-968b-480448f73990.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/oA127iCEFhA/TechDaysVideosAndBalticSeaSwimming.aspx</link>
      <pubDate>Fri, 20 Mar 2009 00:28:22 GMT</pubDate>
      <description>&lt;p&gt;
The videos of TechDays are up:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a title="TOOL302 Code Contracts, Pex and CHESS- 3 Tools, One Talk (englanninkielinen)" href="http://seminaarit.codezone.fi/video/techdays2009/pe-208-2/"&gt;TOOL302
Code Contracts, Pex and CHESS- 3 Tools, One Talk (englanninkielinen)&lt;/a&gt; 
&lt;/li&gt;
&lt;li&gt;
&lt;a title="TOOL404 Pex – Automated White Box Testing for .NET (englanninkielinen)" href="http://seminaarit.codezone.fi/video/techdays2009/pe-208-4/"&gt;TOOL404
Pex – Automated White Box Testing for .NET (englanninkielinen)&lt;/a&gt; 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
While attending TechDays Finland in Helsinki, I had the opportunity (thanks Vesa)
to take a swim in the baltic &lt;strong&gt;frozen&lt;/strong&gt; sea along with fellow Microsoftie &lt;a href="http://www.mostlylucid.net/" target="_blank"&gt;Scott
Galloway&lt;/a&gt; (i’ll spare you the video of the actual bath).
&lt;/p&gt;
&lt;p&gt;
Great way to dust off the remaining of jetlag.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/images/TechDaysBalticSeaSwimming_8120/P3060024.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="P3060024" border="0" alt="P3060024" src="http://blog.dotnetwiki.org/images/TechDaysBalticSeaSwimming_8120/P3060024_thumb.jpg" width="644" height="484" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
ps: Yes we are standing on the sea.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=f6460df9-7923-4374-968b-480448f73990" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,f6460df9-7923-4374-968b-480448f73990.aspx</comments>
      <category>Code Contracts</category>
      <category>Personal</category>
      <category>Pex</category>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/03/20/TechDaysVideosAndBalticSeaSwimming.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=f586ceed-c585-437e-ac44-31644505b7a9</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,f586ceed-c585-437e-ac44-31644505b7a9.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,f586ceed-c585-437e-ac44-31644505b7a9.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=f586ceed-c585-437e-ac44-31644505b7a9</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The next version of Moq 3.0 will work better for <a href="http://research.microsoft.com/pex" target="_blank">Pex</a>:
</p>
        <blockquote>
          <p>
            <a title="http://www.clariusconsulting.net/blogs/kzu/archive/2009/03/05/120009.aspx" href="http://www.clariusconsulting.net/blogs/kzu/archive/2009/03/05/120009.aspx">http://www.clariusconsulting.net/blogs/kzu/archive/2009/03/05/120009.aspx</a>
          </p>
        </blockquote>
        <p>
In the past, Pex would analyze the Moq ‘engine’ code and spend a large amount of time
trying to understand the internals of that framework. In this release, Daniel has
added special annotations (see <a title="Extension Writer Handbook (PDF)" href="http://research.microsoft.com/en-us/projects/pex/guidancepexextensions.pdf">extension
writer Handbook)</a> that shut down the Pex monitoring for certain areas of Moq which
don’t matter to analyse the code under test.
</p>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=f586ceed-c585-437e-ac44-31644505b7a9" />
      </body>
      <title>Moq 3.0 gets Pex friendly</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,f586ceed-c585-437e-ac44-31644505b7a9.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/RZT3AY_69J0/Moq30GetsPexFriendly.aspx</link>
      <pubDate>Sat, 07 Mar 2009 03:15:27 GMT</pubDate>
      <description>&lt;p&gt;
The next version of Moq 3.0 will work better for &lt;a href="http://research.microsoft.com/pex" target="_blank"&gt;Pex&lt;/a&gt;:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;a title="http://www.clariusconsulting.net/blogs/kzu/archive/2009/03/05/120009.aspx" href="http://www.clariusconsulting.net/blogs/kzu/archive/2009/03/05/120009.aspx"&gt;http://www.clariusconsulting.net/blogs/kzu/archive/2009/03/05/120009.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
In the past, Pex would analyze the Moq ‘engine’ code and spend a large amount of time
trying to understand the internals of that framework. In this release, Daniel has
added special annotations (see &lt;a title="Extension Writer Handbook (PDF)" href="http://research.microsoft.com/en-us/projects/pex/guidancepexextensions.pdf"&gt;extension
writer Handbook)&lt;/a&gt; that shut down the Pex monitoring for certain areas of Moq which
don’t matter to analyse the code under test.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=f586ceed-c585-437e-ac44-31644505b7a9" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,f586ceed-c585-437e-ac44-31644505b7a9.aspx</comments>
      <category>Pex</category>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/03/07/Moq30GetsPexFriendly.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=35666880-fe92-4d7e-8e37-aa74796f87a6</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,35666880-fe92-4d7e-8e37-aa74796f87a6.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,35666880-fe92-4d7e-8e37-aa74796f87a6.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=35666880-fe92-4d7e-8e37-aa74796f87a6</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://blog.dotnetwiki.org/images/QuickGraphonCodeContracts_6BA/image.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/images/QuickGraphonCodeContracts_6BA/image_thumb.png" width="244" height="101" />
          </a>
        </p>
        <p>
Ealier this week, we released the <a href="http://research.microsoft.com/contracts" target="_blank">Code
Contracts</a> library for .NET. Since then, I’ve implemented a lot for contracts for
the data structures in <a href="http://www.codeplex.com/quickgraph" target="_blank">QuickGraph</a> .
In this post, I’ll talk about my experience with the contracts…
</p>
        <p>
          <a href="http://blog.dotnetwiki.org/images/QuickGraphonCodeContracts_6BA/image_3.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/images/QuickGraphonCodeContracts_6BA/image_thumb_3.png" width="311" height="569" />
          </a>
        </p>
        <p>
          <strong>Walking through some contracts.</strong>
        </p>
        <p>
Let’s take a look at the contracts of AddEdge, a method that adds an edge to a graph.
Adding an edge to a graph is certainly a fun adventure, when you write contracts for
it. Let’s take a look:
</p>
        <pre class="code">
          <span style="color: blue">public interface </span>
          <span style="color: #2b91af">IMutableEdgeListGraph</span>&lt;TVertex,
TEdge&gt; : ... <span style="color: blue">where </span>TEdge : <span style="color: #2b91af">IEdge</span>&lt;TVertex&gt;
{ <span style="color: gray">/// &lt;summary&gt; /// </span><span style="color: green">Adds
the edge to the graph </span><span style="color: gray">/// &lt;/summary&gt; /// &lt;param
name="edge"&gt;&lt;/param&gt; /// &lt;returns&gt;</span><span style="color: green">true
if the edge was added, otherwise false.</span><span style="color: gray">&lt;/returns&gt; </span><span style="color: blue">bool </span>AddEdge(TEdge
edge);</pre>
        <a href="http://11011.net/software/vspaste">
        </a>
        <a href="http://11011.net/software/vspaste">
        </a>
        <p>
          <strong>Interface contracts</strong>
        </p>
        <p>
Since IMutableEdgeListGraph is an interface, we need to store the contracts in separate
class. To do so,  we ‘bind’ the interface and the contract class to each other
using the ContractClassForAttribute/ContractClassAttribute.
</p>
        <pre class="code">    [<span style="color: #2b91af">ContractClass</span>(<span style="color: blue">typeof</span>(<span style="color: #2b91af">IMutableEdgeListGraphContract</span>&lt;,&gt;))] <span style="color: blue"> public
interface </span><span style="color: #2b91af">IMutableEdgeListGraph</span>&lt;TVertex,
TEdge&gt; ...</pre>
        <a href="http://11011.net/software/vspaste">
        </a>
        <pre class="code">    [<span style="color: #2b91af">ContractClassFor</span>(<span style="color: blue">typeof</span>(<span style="color: #2b91af">IMutableEdgeListGraph</span>&lt;,&gt;))] <span style="color: blue"> sealed
class </span><span style="color: #2b91af">IMutableEdgeListGraphContract</span>&lt;TVertex,
TEdge&gt; : <span style="color: #2b91af">IMutableEdgeListGraph</span>&lt;TVertex,
TEdge&gt; <span style="color: blue">where </span>TEdge : <span style="color: #2b91af">IEdge</span>&lt;TVertex&gt;</pre>
        <a href="http://11011.net/software/vspaste">
        </a>
        <p>
Once both types are bound, you can start implementing the contracts of the interface
in the contract class. Note that the contract class must use <i>explicit</i> interface
implementations for all methods.
</p>
        <p>
          <strong>Basic null checks</strong>
        </p>
        <p>
If you care about null references, the first contract will probably to ensure the
edge is not null. To make it quick and painless, make sure you use the <strong><em>crn</em></strong> snippet.
Note that since the method body of the contracts does not matter, we simply return
the default value.
</p>
        <pre class="code">
          <span style="color: blue">bool </span>
          <span style="color: #2b91af">IMutableEdgeListGraph</span>&lt;TVertex,
TEdge&gt;.AddEdge(TEdge e) { <strong><span style="color: #2b91af">Contract</span>.Requires(e
!= <span style="color: blue">null</span>); <span style="color: blue">return default</span>(<span style="color: blue">bool</span>); </strong>}</pre>
        <a href="http://11011.net/software/vspaste">
        </a>
        <p>
        </p>
        <p>
          <strong>More pre-conditions</strong>
        </p>
        <p>
One of the <em>implicit</em> requirement of AddEdge is that both vertices should already
belong to the graph. We want to make this <em>explicit</em> as a pre-condition as
well:
</p>
        <pre class="code">
          <span style="color: blue">bool </span>
          <span style="color: #2b91af">IMutableEdgeListGraph</span>&lt;TVertex,
TEdge&gt;.AddEdge(TEdge e) { <span style="color: #2b91af">IMutableEdgeListGraph</span>&lt;TVertex,
TEdge&gt; ithis = <span style="color: blue">this</span>; <span style="color: #2b91af">Contract</span>.Requires(e
!= <span style="color: blue">null</span>); <strong><span style="color: #2b91af">Contract</span>.Requires(ithis.ContainsVertex(e.Source)); <span style="color: #2b91af">Contract</span>.Requires(ithis.ContainsVertex(e.Target));</strong></pre>
        <a href="http://11011.net/software/vspaste">
        </a>
        <p>
There are two things to notice here: (1) we had to cast the “this” pointer to the
interface we are writing contracts for, IMutableEdgeListGraph&lt;,&gt;. Because the
methods in a contract class must be explicit interface implementations, we do not
have access to the members of this interface from the “this” pointer, (2) ContainsVertex
had to be annotated with [Pure], as any method called from a contract must be pure: 
</p>
        <pre class="code">[<span style="color: #2b91af">Pure</span>] <span style="color: blue">bool </span>ContainsVertex(TVertex
vertex);</pre>
        <a href="http://11011.net/software/vspaste">
        </a>
        <p>
          <strong>What about post-conditions</strong>
        </p>
        <p>
One of my favorite feature of Code Contracts is to be able to state post-conditions.
This is done by calling the Contracts.Ensures method. For example, we start by expressing
that the edge must belong to the graph when we leave AddEdge:
</p>
        <pre class="code">
          <span style="color: blue">bool </span>
          <span style="color: #2b91af">IMutableEdgeListGraph</span>&lt;TVertex,
TEdge&gt;.AddEdge(TEdge e) { <span style="color: #2b91af">IMutableEdgeListGraph</span>&lt;TVertex,
TEdge&gt; ithis = <span style="color: blue">this</span>;<br />
... 
<br /><span style="color: #2b91af">Contract</span>.Ensures(ithis.ContainsEdge(e));</pre>
        <a href="http://11011.net/software/vspaste">
        </a>
        <p>
          <strong>Result and Old</strong>
        </p>
        <p>
Since the method returns a boolean, we should also state something about the result
value. To refer to the result, one has to use the Contract.Result&lt;T&gt;() method.
In this case,  the method returns true if the edge was new, false if it was already
in the graph. We can refer to a pre-state, i.e. the value of this.Contains(e) at the
beginning of the method***:
</p>
        <pre class="code">
          <span style="color: #2b91af">Contract</span>.Ensures(<span style="color: #2b91af">Contract</span>.Result&lt;<span style="color: blue">bool</span>&gt;() 
<br />
== <span style="color: #2b91af">Contract</span>.OldValue(!ithis.ContainsEdge(e)));</pre>
        <p>
Lastly, we can also make sure the edge count has been incremented, if an edge was
actually added (as you can see, we could use an implication operator in C#):
</p>
        <p>
          <span style="color: #2b91af">Contract</span>.Ensures(ithis.EdgeCount 
<br />
== <span style="color: #2b91af">Contract</span>.OldValue(ithis.EdgeCount) + (<span style="color: #2b91af">Contract</span>.Result&lt;<span style="color: blue">bool</span>&gt;()
? 1 : 0));
</p>
        <p>
*** The OldState value is evaluated after the preconditions.
</p>
        <p>
          <strong>Where to go next?</strong>
        </p>
        <p>
In the next post, I’ll show how to leverage these Contracts with <a href="http://research.microsoft.com/pex" target="_blank">Pex</a>…
</p>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=35666880-fe92-4d7e-8e37-aa74796f87a6" />
      </body>
      <title>QuickGraph on Code Contracts</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,35666880-fe92-4d7e-8e37-aa74796f87a6.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/ZnWMth_usA8/QuickGraphOnCodeContracts.aspx</link>
      <pubDate>Sat, 28 Feb 2009 16:33:15 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/images/QuickGraphonCodeContracts_6BA/image.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/images/QuickGraphonCodeContracts_6BA/image_thumb.png" width="244" height="101" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Ealier this week, we released the &lt;a href="http://research.microsoft.com/contracts" target="_blank"&gt;Code
Contracts&lt;/a&gt; library for .NET. Since then, I’ve implemented a lot for contracts for
the data structures in &lt;a href="http://www.codeplex.com/quickgraph" target="_blank"&gt;QuickGraph&lt;/a&gt; .
In this post, I’ll talk about my experience with the contracts…
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.dotnetwiki.org/images/QuickGraphonCodeContracts_6BA/image_3.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blog.dotnetwiki.org/images/QuickGraphonCodeContracts_6BA/image_thumb_3.png" width="311" height="569" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Walking through some contracts.&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Let’s take a look at the contracts of AddEdge, a method that adds an edge to a graph.
Adding an edge to a graph is certainly a fun adventure, when you write contracts for
it. Let’s take a look:
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public interface &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IMutableEdgeListGraph&lt;/span&gt;&amp;lt;TVertex,
TEdge&amp;gt; : ... &lt;span style="color: blue"&gt;where &lt;/span&gt;TEdge : &lt;span style="color: #2b91af"&gt;IEdge&lt;/span&gt;&amp;lt;TVertex&amp;gt;
{ &lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt; /// &lt;/span&gt;&lt;span style="color: green"&gt;Adds
the edge to the graph &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt; /// &amp;lt;param
name=&amp;quot;edge&amp;quot;&amp;gt;&amp;lt;/param&amp;gt; /// &amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;true
if the edge was added, otherwise false.&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/returns&amp;gt; &lt;/span&gt;&lt;span style="color: blue"&gt;bool &lt;/span&gt;AddEdge(TEdge
edge);&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; 
&lt;p&gt;
&lt;strong&gt;Interface contracts&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Since IMutableEdgeListGraph is an interface, we need to store the contracts in separate
class. To do so,&amp;#160; we ‘bind’ the interface and the contract class to each other
using the ContractClassForAttribute/ContractClassAttribute.
&lt;/p&gt;
&lt;pre class="code"&gt;    [&lt;span style="color: #2b91af"&gt;ContractClass&lt;/span&gt;(&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;IMutableEdgeListGraphContract&lt;/span&gt;&amp;lt;,&amp;gt;))] &lt;span style="color: blue"&gt; public
interface &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IMutableEdgeListGraph&lt;/span&gt;&amp;lt;TVertex,
TEdge&amp;gt; ...&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; &lt;pre class="code"&gt;    [&lt;span style="color: #2b91af"&gt;ContractClassFor&lt;/span&gt;(&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;IMutableEdgeListGraph&lt;/span&gt;&amp;lt;,&amp;gt;))] &lt;span style="color: blue"&gt; sealed
class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IMutableEdgeListGraphContract&lt;/span&gt;&amp;lt;TVertex,
TEdge&amp;gt; : &lt;span style="color: #2b91af"&gt;IMutableEdgeListGraph&lt;/span&gt;&amp;lt;TVertex,
TEdge&amp;gt; &lt;span style="color: blue"&gt;where &lt;/span&gt;TEdge : &lt;span style="color: #2b91af"&gt;IEdge&lt;/span&gt;&amp;lt;TVertex&amp;gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; 
&lt;p&gt;
Once both types are bound, you can start implementing the contracts of the interface
in the contract class. Note that the contract class must use &lt;i&gt;explicit&lt;/i&gt; interface
implementations for all methods.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Basic null checks&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
If you care about null references, the first contract will probably to ensure the
edge is not null. To make it quick and painless, make sure you use the &lt;strong&gt;&lt;em&gt;crn&lt;/em&gt;&lt;/strong&gt; snippet.
Note that since the method body of the contracts does not matter, we simply return
the default value.
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;bool &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IMutableEdgeListGraph&lt;/span&gt;&amp;lt;TVertex,
TEdge&amp;gt;.AddEdge(TEdge e) { &lt;strong&gt; &lt;span style="color: #2b91af"&gt;Contract&lt;/span&gt;.Requires(e
!= &lt;span style="color: blue"&gt;null&lt;/span&gt;); &lt;span style="color: blue"&gt;return default&lt;/span&gt;(&lt;span style="color: blue"&gt;bool&lt;/span&gt;); &lt;/strong&gt;}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; 
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;More pre-conditions&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
One of the &lt;em&gt;implicit&lt;/em&gt; requirement of AddEdge is that both vertices should already
belong to the graph. We want to make this &lt;em&gt;explicit&lt;/em&gt; as a pre-condition as
well:
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;bool &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IMutableEdgeListGraph&lt;/span&gt;&amp;lt;TVertex,
TEdge&amp;gt;.AddEdge(TEdge e) { &lt;span style="color: #2b91af"&gt;IMutableEdgeListGraph&lt;/span&gt;&amp;lt;TVertex,
TEdge&amp;gt; ithis = &lt;span style="color: blue"&gt;this&lt;/span&gt;; &lt;span style="color: #2b91af"&gt;Contract&lt;/span&gt;.Requires(e
!= &lt;span style="color: blue"&gt;null&lt;/span&gt;); &lt;strong&gt; &lt;span style="color: #2b91af"&gt;Contract&lt;/span&gt;.Requires(ithis.ContainsVertex(e.Source)); &lt;span style="color: #2b91af"&gt;Contract&lt;/span&gt;.Requires(ithis.ContainsVertex(e.Target));&lt;/strong&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; 
&lt;p&gt;
There are two things to notice here: (1) we had to cast the “this” pointer to the
interface we are writing contracts for, IMutableEdgeListGraph&amp;lt;,&amp;gt;. Because the
methods in a contract class must be explicit interface implementations, we do not
have access to the members of this interface from the “this” pointer, (2) ContainsVertex
had to be annotated with [Pure], as any method called from a contract must be pure: 
&lt;/p&gt;
&lt;pre class="code"&gt;[&lt;span style="color: #2b91af"&gt;Pure&lt;/span&gt;] &lt;span style="color: blue"&gt;bool &lt;/span&gt;ContainsVertex(TVertex
vertex);&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; 
&lt;p&gt;
&lt;strong&gt;What about post-conditions&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
One of my favorite feature of Code Contracts is to be able to state post-conditions.
This is done by calling the Contracts.Ensures method. For example, we start by expressing
that the edge must belong to the graph when we leave AddEdge:
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;bool &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IMutableEdgeListGraph&lt;/span&gt;&amp;lt;TVertex,
TEdge&amp;gt;.AddEdge(TEdge e) { &lt;span style="color: #2b91af"&gt;IMutableEdgeListGraph&lt;/span&gt;&amp;lt;TVertex,
TEdge&amp;gt; ithis = &lt;span style="color: blue"&gt;this&lt;/span&gt;;&lt;br /&gt;
... 
&lt;br /&gt;
&lt;span style="color: #2b91af"&gt;Contract&lt;/span&gt;.Ensures(ithis.ContainsEdge(e));&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; 
&lt;p&gt;
&lt;strong&gt;Result and Old&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Since the method returns a boolean, we should also state something about the result
value. To refer to the result, one has to use the Contract.Result&amp;lt;T&amp;gt;() method.
In this case,&amp;#160; the method returns true if the edge was new, false if it was already
in the graph. We can refer to a pre-state, i.e. the value of this.Contains(e) at the
beginning of the method***:
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;Contract&lt;/span&gt;.Ensures(&lt;span style="color: #2b91af"&gt;Contract&lt;/span&gt;.Result&amp;lt;&lt;span style="color: blue"&gt;bool&lt;/span&gt;&amp;gt;() 
&lt;br /&gt;
== &lt;span style="color: #2b91af"&gt;Contract&lt;/span&gt;.OldValue(!ithis.ContainsEdge(e)));&lt;/pre&gt;
&lt;p&gt;
Lastly, we can also make sure the edge count has been incremented, if an edge was
actually added (as you can see, we could use an implication operator in C#):
&lt;/p&gt;
&lt;p&gt;
&lt;span style="color: #2b91af"&gt;Contract&lt;/span&gt;.Ensures(ithis.EdgeCount 
&lt;br /&gt;
== &lt;span style="color: #2b91af"&gt;Contract&lt;/span&gt;.OldValue(ithis.EdgeCount) + (&lt;span style="color: #2b91af"&gt;Contract&lt;/span&gt;.Result&amp;lt;&lt;span style="color: blue"&gt;bool&lt;/span&gt;&amp;gt;()
? 1 : 0));
&lt;/p&gt;
&lt;p&gt;
*** The OldState value is evaluated after the preconditions.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Where to go next?&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
In the next post, I’ll show how to leverage these Contracts with &lt;a href="http://research.microsoft.com/pex" target="_blank"&gt;Pex&lt;/a&gt;…
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=35666880-fe92-4d7e-8e37-aa74796f87a6" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,35666880-fe92-4d7e-8e37-aa74796f87a6.aspx</comments>
      <category>Code Contracts</category>
      <category>Pex</category>
      <category>QuickGraph</category>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/02/28/QuickGraphOnCodeContracts.aspx</feedburner:origLink></item>
    <item>
      <trackback:ping>http://blog.dotnetwiki.org/Trackback.aspx?guid=b98ce5ca-514f-4514-81f4-b43d47767dfa</trackback:ping>
      <pingback:server>http://blog.dotnetwiki.org/pingback.aspx</pingback:server>
      <pingback:target>http://blog.dotnetwiki.org/PermaLink,guid,b98ce5ca-514f-4514-81f4-b43d47767dfa.aspx</pingback:target>
      <dc:creator>Jonathan de Halleux</dc:creator>
      <wfw:comment>http://blog.dotnetwiki.org/CommentView,guid,b98ce5ca-514f-4514-81f4-b43d47767dfa.aspx</wfw:comment>
      <wfw:commentRss>http://blog.dotnetwiki.org/SyndicationService.asmx/GetEntryCommentsRss?guid=b98ce5ca-514f-4514-81f4-b43d47767dfa</wfw:commentRss>
      <slash:comments>4</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’ll be travelling in Europe next month and presenting <a href="http://research.microsoft.com/pex" target="_blank">Pex</a>, <a href="http://research.microsoft.com/contracts" target="_blank">Code
Contracts</a> and <a href="http://research.microsoft.com/chess" target="_blank">CHESS</a> in
various events. Don’t forget to swing by, shake a hand and talk about geek stuff.
</p>
        <ul>
          <li>
March 5-6: <a href="http://www.techdays.fi/" target="_blank">TechDays Finland</a>,
in Helsinki, 
</li>
          <li>
March 9: <a href="http://www.dotned.nl/blogs/hassan_fadili/archive/2009/02/18/958.aspx" target="_blank">The
Netherlands .NET user group</a>, in Amsterdam, 
</li>
          <li>
March 10: <a href="http://dnug.org.uk/" target="_blank">London .NET user group</a>,
in London of course, 
</li>
          <li>
March 11-12: <a href="http://www.microsoft.com/belux/techdays/agenda.aspx" target="_blank">TechDays
Belgium</a>, in Antwerp, 
</li>
          <li>
March 13: Katholieke Universiteit Leuven, in Leuven 
</li>
        </ul>
        <p>
See you there!
</p>
        <p>
          <a href="http://www.microsoft.com/belux/techdays/about.aspx">
            <img style="display: inline; margin-left: 0px; margin-right: 0px" title="nav_brain_01" border="0" alt="nav_brain_01" src="http://blogs.msdn.com/blogfiles/charles_sterling/WindowsLiveWriter/TechDaysBelgiumtoStarourveryownTestBrain_A18C/nav_brain_01_3.jpg" width="219" height="184" />
          </a>
        </p>
        <img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=b98ce5ca-514f-4514-81f4-b43d47767dfa" />
      </body>
      <title>Pex Europe Tour March’09</title>
      <guid isPermaLink="false">http://blog.dotnetwiki.org/PermaLink,guid,b98ce5ca-514f-4514-81f4-b43d47767dfa.aspx</guid>
      <link>http://feedproxy.google.com/~r/PelisFarm/~3/srjBmUHvs0c/PexEuropeTourMarch09.aspx</link>
      <pubDate>Wed, 18 Feb 2009 06:45:33 GMT</pubDate>
      <description>&lt;p&gt;
I’ll be travelling in Europe next month and presenting &lt;a href="http://research.microsoft.com/pex" target="_blank"&gt;Pex&lt;/a&gt;, &lt;a href="http://research.microsoft.com/contracts" target="_blank"&gt;Code
Contracts&lt;/a&gt; and &lt;a href="http://research.microsoft.com/chess" target="_blank"&gt;CHESS&lt;/a&gt; in
various events. Don’t forget to swing by, shake a hand and talk about geek stuff.
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
March 5-6: &lt;a href="http://www.techdays.fi/" target="_blank"&gt;TechDays Finland&lt;/a&gt;,
in Helsinki, 
&lt;/li&gt;
&lt;li&gt;
March 9: &lt;a href="http://www.dotned.nl/blogs/hassan_fadili/archive/2009/02/18/958.aspx" target="_blank"&gt;The
Netherlands .NET user group&lt;/a&gt;, in Amsterdam, 
&lt;/li&gt;
&lt;li&gt;
March 10: &lt;a href="http://dnug.org.uk/" target="_blank"&gt;London .NET user group&lt;/a&gt;,
in London of course, 
&lt;/li&gt;
&lt;li&gt;
March 11-12: &lt;a href="http://www.microsoft.com/belux/techdays/agenda.aspx" target="_blank"&gt;TechDays
Belgium&lt;/a&gt;, in Antwerp, 
&lt;/li&gt;
&lt;li&gt;
March 13: Katholieke Universiteit Leuven, in Leuven 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
See you there!
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.microsoft.com/belux/techdays/about.aspx"&gt;&lt;img style="display: inline; margin-left: 0px; margin-right: 0px" title="nav_brain_01" border="0" alt="nav_brain_01" src="http://blogs.msdn.com/blogfiles/charles_sterling/WindowsLiveWriter/TechDaysBelgiumtoStarourveryownTestBrain_A18C/nav_brain_01_3.jpg" width="219" height="184" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.dotnetwiki.org/aggbug.ashx?id=b98ce5ca-514f-4514-81f4-b43d47767dfa" /&gt;</description>
      <comments>http://blog.dotnetwiki.org/CommentView,guid,b98ce5ca-514f-4514-81f4-b43d47767dfa.aspx</comments>
    <feedburner:origLink>http://blog.dotnetwiki.org/2009/02/18/PexEuropeTourMarch09.aspx</feedburner:origLink></item>
  </channel>
</rss>
