Martin,
I am testing at the Module level, so i dont haveto worry about ASP.NET.
I call into the DB with a section ID, so it can get the exact module i need and test away.
I want to also write some integration tests at this level too.
From the Module down i am not hit by the HTTPCONTEXT not being there. Maybe a few things further down might need some mocking though.
Here the complete code. Its not refactored out at all so its easy to see whats happening.
The main problem is that the Casle NHibernate facility is forcing the creation of the Castle.Facilities.NHibernateIntegration.Internal.WebSessionStore.
I tried removing the httpHodule line but no luck.
Theres a forum post, but nothign conclusive.
http://forum.castleproject.org/viewtopic.php?t=1531
I feel this would be very useful for any Cuyahoga users.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using log4net;
using Cuyahoga.Core.Domain;
using Cuyahoga.Core.Service;
using Cuyahoga.Core.Service.SiteStructure;
using Cuyahoga.Core.Util;
using Cuyahoga.Tests.Util;
using Cuyahoga.Tests.Components;
using Cuyahoga.Modules.Downloads;
namespace Cuyahoga.Tests
{
[TestFixture]
public class DownloadModuleTests
{
//private static ILog log = LogManager.GetLogger(System.Reflection.Assembly.GetExecutingAssembly().GetType());
private static ILog log = LogManager.GetLogger(typeof(DownloadModuleTests));
private CuyahogaContainer _cuyahogaContainer;
private ISectionService _sectionService;
private ModuleLoader _moduleLoader;
DownloadsModule mod;
// Constr
public DownloadModuleTests()
{
// Plumb up base to load up all modules into the container
log4net.Config.XmlConfigurator.Configure();
// Createa Base Class for this
_cuyahogaContainer = new CuyahogaContainer();
this._sectionService = _cuyahogaContainer.Resolve(ISectionService);
this._moduleLoader = _cuyahogaContainer.Resolve(ModuleLoader);
// !!! It BOMBS OUT here with the exception above
int sectionId = 1;
string pathInfo = "pathinfo";
string content = null;
Section section = this._sectionService.GetSectionById(sectionId);
ModuleBase moduleBase = this._moduleLoader.GetModuleFromSection(section);
moduleBase.ModulePathInfo = pathInfo;
// Cast it
mod = (DownloadsModule)moduleBase;
}
[Test]
public void Test01()
{
Console.WriteLine("Hello world");
IList list = mod.GetAllFiles();
}
}
}