/// <summary>
        /// Sets up the template for a call to <see cref="IWordTemplate.CreateBuildingBlock"/>.
        /// </summary>
        /// <param name="layoutName">The name of the layout.</param>
        /// <param name="blockName">The name of the building block.</param>
        /// <param name="startPosition">Start position for the building block.</param>
        /// <param name="endPosition">End position for the building block.</param>
        private void SetupTemplateForCreateBuildingBlock(string layoutName, BuildingBlockName blockName, int startPosition, int endPosition)
        {
            Mock <BuildingBlock> mockBuildingBlock = new Mock <BuildingBlock>();

            mockBuildingBlock.Setup(bb => bb.Name).Returns(blockName.ToString());
            this.mockWordTemplate.Setup(t => t.CreateBuildingBlock(CategoryPrefix + layoutName, blockName.ToString(), startPosition, endPosition)).Returns(mockBuildingBlock.Object);
        }
        /// <summary>
        /// Gets a named building block from a layout.
        /// </summary>
        /// <param name="layout">The layout for which the building block is to be retrieved.</param>
        /// <param name="name">The name of the building block to retrieve.</param>
        /// <returns>The named <see cref="BuildingBlock"/> from the given layout.</returns>
        public BuildingBlock GetLayoutBuildingBlock(LayoutInformation layout, BuildingBlockName name)
        {
            if (layout == null)
            {
                throw new ArgumentNullException("layout");
            }

            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            BuildingBlock ans = null;
            Dictionary <string, BuildingBlock> layoutBlockDictionary = null;

            if (!this.buildingBlockCache.TryGetValue(layout.Name, out layoutBlockDictionary))
            {
                IEnumerable <BuildingBlock> blocks = this.wordTemplate.EnumerateBuildingBlocksForCategory(CategoryPrefix + layout.Name);
                this.AddLayoutBlocksToCache(layout.Name, blocks);
                layoutBlockDictionary = this.buildingBlockCache[layout.Name];
            }

            if (layoutBlockDictionary != null)
            {
                layoutBlockDictionary.TryGetValue(name.ToString(), out ans);
            }

            return(ans);
        }