Damned Nodes!


Test driven Umbraco by a backend developer

welcome!


My name is:

I work at: 

I'm not an umbraco developer

I'm a software engineer

I like 

principles 

and layers

 and tests

 and....



Separation Of Concerns

Umbraco the problem  Challenge



  • Decoupling
  • MVC
  • Controller like structure

public class DynamicNode : DynamicObject, Inode

//this is basically a façade / service container like thingy of almost 2k lines

Umbraco the problem  Challenge


public interface INode
    {
        List<INode> ChildrenAsList { get; }
        DateTime CreateDate { get; }
        int CreatorID { get; }
        string CreatorName { get; }
        int Id { get; }
        int Level { get; }
        string Name { get; }
        string NiceUrl { get; }
        string NodeTypeAlias { get; }
        INode Parent { get; }
        string Path { get; }
        List<IProperty> PropertiesAsList { get; }
        int SortOrder { get; }
        int template { get; }
        DateTime UpdateDate { get; }
        string Url { get; }
        string UrlName { get; }
        Guid Version { get; }
        int WriterID { get; }
        string WriterName { get; }
        DataTable ChildrenAsTable();
        DataTable ChildrenAsTable(string nodeTypeAliasFilter);
        IProperty GetProperty(string Alias);
        IProperty GetProperty(string Alias, out bool propertyExists);
    }

dynamics and runtime and .net


macro's as partial views and controllers


PageController pageController = ObjectFactory.GetInstance<pagecontroller>();
  Contentpage viewModel = pageController.Contentpage(uQuery.GetCurrentNode());
  if (viewModel.HasRedirect)
  {
    Response.Redirect(viewModel.RedirectUrl);
  } 
    //..view code (called from masterpage -> masterpage per contenttype)

testing your application


public class StubNode : DynamicObject, INode

public interface IUmbracoContentRepository
{       
    INode NodeById(int nodeId);
	//etc
}

public interface IUmbracoNodeToModelMapper<out TModel>

public abstract class UmbracoContentServiceBase<TModel> : IContentService<TModel>
{       
        protected UmbracoContentServiceBase(IUmbracoContentRepository umbracoContentRepository, IUmbracoNodeToModelMapper<TModel> mapper)
        public abstract TModel GetModel();
        public abstract TModel GetModelForNodeId(int nodeId);
} 

Testing your application


public class StubNode : DynamicObject, INode

macro's as partial views and controllers


PageController pageController = ObjectFactory.GetInstance<pagecontroller>();
  Contentpage viewModel = pageController.Contentpage(uQuery.GetCurrentNode());
  if (viewModel.HasRedirect)
  {
    Response.Redirect(viewModel.RedirectUrl);
  } 
    //..view code (called from masterpage -> masterpage per contenttype)

So....


  • Set of interfaces
  • base and helper classes

To make Umbraco reasonably testable

Damned Nodes

By dverhoeckx

Damned Nodes

Test driven Umbraco by a backend developer

  • 3,586