Just a quick note before continuing. In NHibernate, most tests inherits from the abstract NHibernate.Test.TestCase class. This class is responsible for the infrastructure of the test. By that I mean that it instansiate a Session Factory, create the appropriate tables, etc.
A test fixture specify how to find its mapping using these two properties:
/// <summary>
/// Mapping files used in the TestCase
/// </summary>
protected abstract IList Mappings { get; }
/// <summary>
/// Assembly to load mapping files from (default is NHibernate.DomainModel).
/// </summary>
protected virtual string MappingsAssembly
{
get { return "NHibernate.DomainModel"; }
}
Creating a session is done by calling the protected method OpenSession().
This frees the tester from dealing with all those issues. (Just automatically creating the tables is a huge burden of my chest).
One important thing to note is that NHibernate expect the test to clean up after itself. It should close the session, delete any data that you put in the database and close any connections that you have opened.
If you are interested in modifying the configuration (as I did, to add support for second level caching), you can access the base.Cfg variable, and modify it, and then generate a new session factory from that.
That is enough details for now, I think.