# Monday, August 23, 2010

We have added a new step-by-step tutorial to help testing Asp.NET applications with Pex and Moles. You will find as part of the installer or simply at

http://research.microsoft.com/en-us/projects/pex/molesaspnet.pdf

posted on Monday, August 23, 2010 10:15:33 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]
# Monday, June 28, 2010

Is there anything else to say than… try it out now at http://www.pexforfun.com !

image

posted on Monday, June 28, 2010 2:35:18 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]
# Monday, June 07, 2010

We’ve just released a new version of Pex and Moles v0.92. This version brings Rex integration (smarter about regular expressions), Silverlight support (Alpha) and a number of bugs/improvements here and there.

Read all about the new stuff on the release notes page. Happy Pexing!

posted on Monday, June 07, 2010 12:13:52 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [2]
# Friday, June 04, 2010

I just uploaded a refresh of the QuickGraph binaries with Code Contracts references and documentation instrumented with the Contracts.

image

posted on Friday, June 04, 2010 7:34:36 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]
# Monday, May 24, 2010

Are you using Code Contracts ? or not? Give us 5 minutes of your time and fill up the survey that the BCL has put up…

http://codecontracts.questionpro.com/

posted on Monday, May 24, 2010 8:42:30 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]
# Tuesday, May 18, 2010

 

This post shows how you can leverage the un-typed Detours API to extend any mock framework to support static methods, sealed types, etc…

Moles is an isolation framework for .NET that the Pex team designed to make Pex happy. It relies heavily on delegates and comes with a syntax of its own. Moles is actually a simple strongly typed layer on top of a un-typed general purpose detour API. If you do not like the Moles syntax, you can still leverage the detours API to deal with static methods or sealed types.

Let us see how we can use the detour API to build a micro-mock-framework using expressions trees. Let’s call it Deq.

The Challenge

As usual, we’ll toy with an example where we need a very particular DateTime.Now value. Since DateTime.Now is a struct living in mscorlib.dll, it cannot be mocked using traditional approaches –DateTime.Now can’t be overloaded. The test case looks like this and will most likely fail.

image The Whish

We would like to be able to replace the implementation of DateTime.Now with a method that always returns the year 2000 in the context of the test. If possible, we would like to use a strongly typed, Linq-ish, expression tree based syntax to do this. For example, we could think that a Deq class would define a Replace(Expression<Func<T>> method, Func<T> detour) method that would achieve this detour:

image

 Implementing Deq on top of MoleRuntime

The implementation of Deq.Replace relies on MoleRuntime.SetMole, an un-typed API to replace methods that Moles builds upon. First, one needs to walk the expression tree to extract the MethodInfo that the user wanted to replace (I’m not showing this code here, it is beyond the point of this blog post). Once you have the method, you can use the Moles API to install the detour. This happens through the MoleRuntime.SetMole method and the rest is taken care of the Moles runtime.

imageThat’s it. You’ve just written a micro-mock framework that can isolate from static methods.

To get this code to compile, you will need a reference to Microsoft.ExtendedReflection.dll and Microsoft.Moles.Framework.dll. Also, since the Replace method only works for the Func<T> method, you’ll probably want to write a T4 template that takes care of all the other delegates (Func<T,T2>, Action<…> etc…).

Deq Sources?

The Deq sources are available in the Samples solution that ships with Pex.

posted on Tuesday, May 18, 2010 9:30:10 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]
# Sunday, May 16, 2010

Nikolai Tillmann announced it on our page, he just finished integrating Rex in to Pex….

posted on Sunday, May 16, 2010 9:55:16 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]
# Saturday, May 01, 2010

Although Pex is only available for MSDN subscribers, Moles can be freely downloaded as a standalone tool on Visual Studio Gallery.

http://visualstudiogallery.msdn.microsoft.com/en-us/b3b41648-1c21-471f-a2b0-f76d8fb932ee

(off course, both tools are also available under an academic license too)

posted on Saturday, May 01, 2010 4:36:45 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]
# Saturday, April 24, 2010

We just uploaded a new release 0.91 on MSDN, Visual Studio gallery and our research web site. Learn more about the changes at http://research.microsoft.com/en-us/projects/pex/releasenotes.aspx#0_91

Get and download Pex!

posted on Saturday, April 24, 2010 6:51:44 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]
# Friday, April 16, 2010

Are you using Pex and/or Moles? Do you want to become a fan (on Facebook)? It’s possible now!!!

Pex and Moles on Facebook

posted on Friday, April 16, 2010 6:06:31 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]