I can not test it at the moment but you may have to do the object creation inside a wrapper method.
public static void TestWrapper(String foo, Int32 bar, Boolean buzz, Decimal foobar)
{
var thing = new Thing(foo, bar);
thing.Buzz = buzz;
Test(thing, blah);
}
public static Test(Thing thing, Decimal foobar)
{
thing.DoStuff();
if (thing.State == 42)
{
thing.DoOtherStuff(foobar);
}
}
In my experience Pex yields really great results when you use it to analyze methods that are close to mathematically functions with not to many side effects and especially state mutation. Tracking changing state over time and finding sequences of operations to prepare an object to a certain state and then checking the behavior of the object in this state is much harder than analyzing a (almost) pure function.
You can test it online at pex4fun.com. Here are two tests, one using a function that takes built-in types as parameters and instantiates a Thing to operate on, and a second that takes a Thing input and operates on it directly. It seems to generate interesting cases for both, but it's much more easily readable with the more basic input types, as the parameters are easily displayed in the table.
Nice. If you use the second variant you have to click an a test case to see which arguments have been passed to the constructor of Thing. Just from the tabular view most test cases look identical.