April 2011 Blog Posts

Dependency Injection with Ninject and Mocking with MoQ

Today it's my great pleasure to lead the discussion about Dependency Injection with Ninject and Mocking with MoQ at the SEVDNUG. Our purpose as software developers is to orchestrate together loosely coupled, well tested components.  Yet far too often, our code turns into a big ball of mud.  These two tools and their supporting techniques can create loosely coupled, eagerly testable code that will make you much more productive. Our starting place is this, an n-tier app with hard-coded dependencies.  This is very hard to unit test.  I grant there's good separation of concerns here, and that typically that's harder than it...

HtmlHelper for something that isn't the Model in ASP.NET MVC

I'm in the midst of a Razor View, and I want to use things like @Html.EditorFor(model => model.ProductId) but the model isn't a Product, it's a composite type for this view that looks like this: public class SomeViewModel {     public Product Product { get; set; }     public List<Irrelevant> IrrelevantList { get; set; } } Well, I can say @Html.EditorFor(model => model.Product.ProductId) but now the markup on my page says <input type="irrelevant" id="Product_ProductId" name="Product.ProductId" /> Two problems here: 1. That's ugly. 2. The post ActionMethod takes in a Product, so the model binder doesn't work right. I really want an HtmlHelper<Product> So, I gin one up like so: var ProductHtml = new HtmlHelper<User>( this.ViewContext, new ViewDataContainer2 { ViewData...

CruiseControl.NET home page link to latest build

I often find that I hit the CruiseControl.NET home page, see red on a build, and specifically want the latest build report. I could click the Project Name link then the latest build link, but that intermediate page isn't buying me much. What I'd really like is the last build time to be a link to this latest build report. I cracked open the webdashboard folder, and inside the templates directory was the magic sauce. I modified ProjectGrid.vm line 127 from:     <td>$projectGridRow.LastBuildDate</td> to     <td><a...