Failure is inevitable


Easily override ToString using Moq

I recently discovered a rather annoying limitation in Moq: you cannot setup expectations on the ToString method.  For a good discussion of the issue, check out Sean’s post.  His solution was to add ToString explicitly to the interface you are mocking, but I don’t want to dirty up my interfaces unnecessarily.  Fortunately, Moq does allow you to create mocks that implement multiple interfaces, so you could move the ToString method to a dummy interface, and use Mock<T>.As to setup expectations on the dummy interface.  That’s the approach I took, but I wrapped it up in a ... [More]

Extending Moq: returning multiple results via lambdas

I have on several occasions wished that I could setup expectations in Moq for subsequent calls to a method.  For example, I might want Moq to return one value the first time a method is called, but a different value the second and third times.  Phil Haack has a nice way to achieve this, but his implementation only allows you to return a result.  What if you need something more advanced?  What if you want to return a value on the first call, throw an exception on the second, and return a value again on the third?  I ran into exactly this situation while testing out some... [More]

Using StructureMap to provide strongly-typed access to AppSettings

I’ve been using StructureMap for the last couple of months.  I love it, and my only regret is that I didn’t start using it sooner.  I always felt like I wrote clean, testable code before, but I can see a noticeable improvement since jumping on the IoC container bandwagon. If you aren’t using an IoC container and are working on anything above a trivially simple app, you should look in to it.  Anyway, I’m knee deep in rewriting our crawler infrastructure, and I found myself working with some classes that need access to external configuration data.  The config data is all fa... [More]

MLSharp 1.0 Alpha Released

I’ve finally written a little bit of documentation on MLSharp, fixed a few bugs/glitches, and packaged it all up into the first official release.  I consider the software Alpha quality (meaning it has known bugs, limitations, may set fire to your house, etc), but I have used it in several projects successfully.  Please give it a look, and let me know if you find it useful. 

A Newbie&rsquo;s Experiences with NDepend

Disclaimer: Yes, I was given a pro license to NDepend.  However, what follows are my honest impressions of version 2.12.1 of the tool on a real .NET 3.5 project.  I have not evaluated the recent beta, so some of the issues noted below may be fixed in a more recent build.  To Patrick Smacchia: I apologize for taking so long to provide feedback on NDepend.  I hope you find the feedback below useful.  Thanks for giving me the chance to check out this cool tool! NDepend is a complex and powerful tool for static code analysis.  The basic idea is that you feed it ... [More]

The trials and tribulations of using MSDeploy with PowerShell

I can sum my experience with trying to use MSDeploy and Powershell together with a single word: hell.  MSDeploy.exe does not play nicely with PowerShell, but thanks to some help from James and a lot of trial-and-error, I’ve got it sort-of working now.  Here’s a tail of my journey.  Hopefully you, brave reader, will learn from my mistakes.  THAR BE DRAGONS HERE. It began with the automation of deployments This journey started from a desire to automate our deployment processes.  We have three different software applications that we host under a SaaS model, and only one... [More]