Geeks With Blogs
John Smith's Blog Keeping the fun machine running one nickel at a time

I’ve refactored part of the project and removed the generic methods, and added in a few new public methods to illustrate building a real sandwich.

To keep the example a bit realistic, I’m leaving the Crunchy layer in a rougher state and building up the Creamy layer.  I’m not a big fan of crunchy peanut butter sandwiches, but in a pinch it will do.  Pressing on.


Our solution looks like this now.

image image











I’ve asked Pex to go back through the solution and hook up PUTs for me.  One notable thing to mention here about rerunning Pex Explorations.   During my refactoring I broke the contract between the facade manager PUTs that Pex had already created.   And Pex said, “So what!”  So the solution would not build, because of this, but the facade library would build – your code needs to build.  Pex will try to regenerate what it needs on its own during the Exploration process. 

In some cases there was code that I could have corrected (namespaces, etc.) and in some cases I did, but in some cases I dropped the test project and stepped back through the previous steps we’ve covered to rebuild the PUT project. 

In the project I was first testing Pex with, I did this a few times and it was not a big deal, especially since I had my PUTs versioned in a source control system.

Here’s what the Pex Explorer looks like now, the Crunchy layer methods are throwing NotImplemented exceptions right now.  We’ll deal with those as well but not right now.















The Pex Explorer has a different view of things now as well.  The ctor for the CreamyLayerManager is the “target”, and Bread.Wheat (an enum) is being passed in to the manager’s AddBread method.  The “Details” text box is displaying the AddBread01 test method and how the target is being created and the methods being called on it. 



This dialog shows us a few other things as well.  Beneath the test method details we have a “Save Test…” button which corresponds to the icon in the far left grid’s gutter.  That icon means we have a new test, that needs to be saved.  And yes, you’ll get used to that. 


Additionally, we have a visual prompt for “1 Object Creation”.



Pex wants to help us stub out a factory to create this particular layer manager.  When we click the Accept (if it’s new) / Edit (if it’s not) button Pex will prompt to tell us it’s about to alter our PUT project, like this.  Very cool – no surprises, right!?  Clicking “Apply”.





Pex Exploration Results change to tell us (visually) something good has happened, and the Factory has been added and we should be looking at it in our code editor, which we are.  This is the type of behavior that Pex is delivering, so you don’t get lost and can follow what’s going on.




At this point, I’m going to add all of the other factories Pex may have suggested as well as the other test methods that need to be saved.

Remember the methods that were throwing exceptions, well those come into play now as well.



A few things to note with this exploration, the test is still passing in a “wheat” argument like the other method that’s not throwing, but Pex has picked up on the fact that it is throwing something intentionally.   The test still needs to be saved, and the exception still needs to be allowed.  


In a better scenario, when may have a guard condition on an argument when it’s passed in.  If it was null, we could throw if it ways.  In this scenario Pex would setup a test that allows for this scenario to happen and would build up a PUT with a null argument so we can get coverage on that part of the code block.  On a live project, you might have these laying around, and it’s perfectly fine.


Clicking “Allow Exception” looks like this.



The tests that are expecting to throw are just like all other tests that throw.  The point is just to make Pex aware so when I come back to flesh out these types, the PUTs will change based on my changes, but because of Pex’ interaction. 


My test runner (xUnit) is telling us the same stuff Pex told us.  These will stay in the red stage until we’re ready make them green.



Before I close on this one, I wanted remind everyone again that I did have to regenerate my PUT project a couple of times over the course of setting up the PUT project and refactoring my code since this is a new Pex build.  This probably won’t happen now that most of the groundwork is laid, and we’ll work more with Pex, and less with the source code.


Until then.

Posted on Wednesday, May 20, 2009 3:41 PM | Back to top

Comments on this post: Flex Your Pex (Part 3)

# re: Flex Your Pex (Part 3)
Requesting Gravatar...
I have learn several good stuff here. Definitely worth bookmarking for revisiting. I surprise how a lot attempt you set to make this type of magnificent informative site.
future stock
Left by ray12 on Jun 06, 2013 12:13 AM

# re: Flex Your Pex (Part 3)
Requesting Gravatar...
Le plus facile à comprendre l'essence de l'écoute est en fait l'écoute sur la position changeante, ses changements sonores prennent du temps. Les pièces défectueuses ou endommagées de la montre seront avec le changement de position, de prendre le son va aussi changer de faon significative. Certains vont changer périodiquement, tandis qu'une grande peu son moment. Pour cette raison, l'écoute de la montre ne peut détecter si la montre est défectueux, et ne peut pas représenter pleinement la qualité de la montre. Mais pour la personne moyenne, l'écoute montre nécessite de l'expérience, faire la replique montre meilleure comparaison, est d'écouter plus de formation, différentes dimensions structurelles de la montre où aller quand le son n'est pas le même. De manière générale, la forme masculine pour être plus solide, la forme féminine est beaucoup plus petite. Quant à l'emplacement de la table à écouter, si vous voulez choisir de porter une position commune - qui est, plat, plat, y compris "cadran en bas de la surface du disque et de la table."
Left by Angela on Jun 28, 2013 4:08 PM

# re: Flex Your Pex (Part 3)
Requesting Gravatar...
Cool post, i like that :)<br>Klik Disini
Left by rachmadp24 on Jan 13, 2014 4:32 PM

# re: Flex Your Pex (Part 3)
Requesting Gravatar...

The article posted was very informative and useful
Left by jaring safety on Oct 11, 2014 9:16 AM

Your comment:
 (will show your gravatar)

Copyright © onefloridacoder | Powered by: