Unit testing code which uses Umbraco v4 API

I'm trying to write a suite of integration tests, where I have custom code which uses the Umbraco API. The Umbraco database lives in a SQL Server CE 4.0 database (*.sdf file) and I've managed to get that association working fine.

My problem looks to be dependancies in the Umbraco code. For example, I would like to create a new user for my tests, so I try:

var user = User.MakeNew("developer", "developer", "mypassword", "my.email@email.com", adminUserType);

Now as you can see, I have pass a user type which is an object. I've tried two separate ways to create the user type, both of which fail due to a null object exception:

var adminUserType = UserType.GetUserType(1);
var adminUserType2 = new UserType(1);

The problem is that in each case the UserType code calls it's Cache method which uses the HttpRuntime class, which naturally is null.

My question is this: Can someone suggest a way of writing integration tests against Umbraco code? Will I have to end up using a mocking framework such as TypeMock or JustMock?

Answers


Here are some resources that may help:

http://www.aaron-powell.com/unit-testing-with-umbraco

http://stream.umbraco.org/video/726639/aaron-powell-unit-testing


Need Your Help

Using Servicestack WSDL with php

wsdl servicestack

I am trying to use ServiceStack to replace WCF for a self hosted service, accessed with a PHP client that forms its messages from on the WSDL.

Using Waypoints to fade in div when in view while fade out remaining divs when scrolling

scroll opacity

Was wondering if you guys can point me in the right direction, my brain's a bit fried at the moment from pulling an all-nighter.