Wednesday, November 25, 2015

Creating MongoDB Shards and Replica Sets with PowerShell

In the MongoDB University course "M101N: MongoDB for .NET Developers", there is a walk through of a UNIX script to create a 3x3 set of shards and replica sets. To brush up on my MongoDB and my Powershell, I decided this weekend to try to rewrite and extend the script in Powershell. A somewhat painful, but ultimately rewarding, experience: You can see what I came up with here.  In this post I will walk through some of the powershell and some of the MongoDB syntax and tricks.

Wednesday, November 18, 2015

Custom Sitecore Log files

Starting with Sitecore 6.2, and especially since Sitecore 7 we've seen an increase in specific log files: WebDAV, Crawling, Search, Publishing, FXM. This is completely configurable, and can be leveraged to keep your application logic separate from the Sitecore log file while still using Sitecore's logging capabilities.

Wednesday, November 11, 2015

Autofac Aggregate Service

There is a nice little feature of Autofac called Aggregate Service, that works very well with NSubstitute's recursive mock functionality to make tests much more maintainable and resilient to dependency modifications.

Wednesday, November 4, 2015

A RoboMongo Trick

RoboMongo is a nice tool for digging around xDB databases. It provides the full feature set of the JavaScript shell (you can save variables, run help commands, etc.) and allows you to do things like edit documents directly through the JSON display.

Wednesday, October 28, 2015


One of the key benefits of unit testing is that it pushes you to code to abstractions. Each class has a clear inside and outside, and your tests document the inside bits. The outside stays wrapped in an interface or abstract class so we can change its behavior in tests. When you go down this path, having a tool to make fake versions of interfaces in a simple and painless way is key, which is why I recommend NSubstitute. It is elegantly simple, very flexible, and makes it hard to get into trouble. In this post I will go over some fundamentals of NSubstitute, and compare them to how things work in the more well known Moq library.

Wednesday, October 21, 2015

Unit Testing an Event Handler with Sitecore.FakeDB

In my last post, we looked at how to make an event handler unit testable by wrapping an interface around the Sitecore log, so that we could use NSubstitute to verify the calls made to it.

This only part of the story, of course. For our tests to be meaningful, we need to be able to "arrange" the input that goes into our code, before we make it "act" and before we "assert" how it should behave. Since we are building an ItemSaved handler, we need a way to create Sitecore items in our unit tests.  There is a tool, Sitecore.FakeDB, that makes this straigtforward.

Wednesday, October 14, 2015

Testable Event Handlers using Sitecore's Configuration Factory

It's a not widely know feature of Sitecore configuration that it allows you to specify parameters for event handlers and pipeline processors. This can be used in combination with wrapper interfaces to write unit testable Sitecore code.

Sunday, September 27, 2015

Test Driven Sitecore Links

I'm honored to be speaking at the SUGCON conference in New Orleans next Thursday on Test Driven Development with Sitecore.  Here are some links related to the talk.

Saturday, July 4, 2015

A Scrum Reading List

On a recent project I played a pretty active, if informal, role as an agile coach, in addition to my development duties. Which meant I did a lot of reading on plane flights, watched a lot of Jeff Sutherland videos, and got to the point where I could quote the Scrum Guide in chapter and verse. I'm not a certified anything (well at least as far as Agile is concerned), but the material started to make sense to me in a fairly coherent way, so I thought it might be useful to assemble a list of resources that influenced my thinking, and what I learned from them.

Sunday, February 8, 2015

MongoDB for Sitecore

Starting with Sitecore 7.5, MongoDB has become an integral part of the Sitecore ecosystem. This post will walk developers through the process of installing MongoDB, and cover some of the basics of MongoDB CRUD operations, and then look at how to access Sitecore data with MongoDB.