I had two small “breakthroughs” while coding today that saved me quite a bit of time.  The first dealt with mocking HtmlHelper<T> with Moq for unit testing purposes:

/// <summary>
/// A mocked-out <see cref="HtmlHelper{TModel}"/> that can be used for testing.
/// </summary>
/// <typeparam name="TModel">The view model type.</typeparam>
public class FakeHtmlHelper<TModel> : HtmlHelper<TModel> where TModel : class
{
    /// <summary>
    /// Creates the fake.
    /// </summary>
    public FakeHtmlHelper(TModel model) : base(new FakeViewContext(), GetMockContainer(model))
    {
        
    }

    /// <summary>
    /// Gets a mock view data container that returns view data for the specified model.
    /// </summary>
    /// <param name="model"></param>
    /// <returns></returns>
    private static IViewDataContainer GetMockContainer(TModel model)
    {
        var dataContainer = new Mock<IViewDataContainer>();

        ViewDataDictionary<TModel> dataDictionary = new ViewDataDictionary<TModel>(model);

        dataContainer.Setup(c => c.ViewData).Returns(dataDictionary);

        return dataContainer.Object;
    }
}

(Note that FakeViewContext is a similarly-designed fake class, but it could also be a Mock object.)

With this fake helper, you can now unit test extension methods for HtmlHelper<T>. 

The second “snippet” I found useful today was aligning a group of divs.  The desired layout was something like the following:

inlineBlockGood

However, setting the divs to display to inline-block resulted in something like this instead, where the div with less content did not line up with the other divs even though their heights were all set to the same value

inlineBlockBad

A quick scan of the CSS spec got me pointed back in the right direction, and I used a vertical-align of top to achieve the desired layout.