Did you put the mapping file for Task as embedded resource?
On Tue, Jan 6, 2009 at 12:39 AM, Brendan Rice <[email protected]>wrote:
>
> Hi,
>
> I am trying to get Rhino-Commons Repositories up and running for a
> domain model and am having a bit of trouble with configuration. I
> have a Unit test class that is shown below. The unit test fails at
> this line with the exception message shown below:
>
> Repository<Task>.Save(new Task(taskName, taskNotes, 0, null));
>
> The Components.Config class is shown below. Any help with this
> exception is appreciated.
>
> Thanks in advance.
>
> Brendan
>
>
> ********************************************************************************************
> * UNIT TEST
> CLASS
> *
>
> ********************************************************************************************
> <?xml version="1.0" encoding="utf-8" ?>
> <configuration>
> <components>
> <component id="nhibernate.repository"
> service ="Rhino.Commons.IRepository`1,
> Rhino.Commons.NHibernate"
> type="Rhino.Commons.NHRepository`1,
> Rhino.Commons.NHibernate"/>
> <component id="nhibernate.unit-of-work.factory"
> service
> ="Rhino.Commons.IUnitOfWorkFactory,
> Rhino.Commons.NHibernate"
>
> type="Rhino.Commons.NHibernateUnitOfWorkFactory,
> Rhino.Commons.NHibernate"/>
> </components>
> </configuration>
>
>
> ********************************************************************************************
> * UNIT TEST
> CLASS
> *
>
> ********************************************************************************************
> using System;
> using System.Collections.Generic;
> using System.IO;
> using MbUnit.Framework;
> using Rhino.Commons;
> using Rhino.Commons.ForTesting;
> using TuhDoo.Core.Domain;
>
> namespace TuhDoo.Core.Tests.Domain
> {
> [TestFixture]
> public class TaskTest : DatabaseTestFixtureBase
> {
> [SetUp]
> public void TestInitialize()
> {
> Environment.CurrentDirectory =
> AppDomain.CurrentDomain.BaseDirectory;
> IntializeNHibernateAndIoC(PersistenceFramework.NHibernate,
> Path.GetFullPath(@"Config\Components.config"),
> MappingInfo.FromAssemblyContaining<Task>());
> CurrentContext.CreateUnitOfWork();
> }
>
> [Test]
> public void Creation()
> {
> string taskName = "Test task 1";
> string taskNotes = "Notes for test task 1";
>
> Repository<Task>.Save(new Task(taskName, taskNotes, 0,
> null));
>
> ICollection<Task> tasks = Repository<Task>.FindAll();
>
> Assert.AreEqual(1, tasks.Count);
>
> With.Each(
> tasks,
> t => Assert.AreEqual(taskName, t.Name));
>
> CurrentContext.DisposeUnitOfWork();
>
> }
> }
> }
>
>
>
> ********************************************************************************************
> *
> EXCEPTION
> *
>
> ********************************************************************************************
> TestInitialize.Creation : Failed*** Failures ***
> Exception
> NHibernate.MappingException: No persister for: TuhDoo.Core.Domain.Task
> at NHibernate.Impl.SessionFactoryImpl.GetEntityPersister(String
> entityName)
> at NHibernate.Impl.SessionImpl.GetEntityPersister(String
> entityName, Object obj)
> at
> NHibernate.Event.Default.AbstractSaveEventListener.SaveWithGeneratedId
> (Object entity, String entityName, Object anything, IEventSource
> source, Boolean requiresImmediateIdAccess)
> at
>
> NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.SaveWithGeneratedOrRequestedId
> (SaveOrUpdateEvent event)
> at
>
> NHibernate.Event.Default.DefaultSaveEventListener.SaveWithGeneratedOrRequestedId
> (SaveOrUpdateEvent event)
> at
> NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.EntityIsTransient
> (SaveOrUpdateEvent event)
> at
> NHibernate.Event.Default.DefaultSaveEventListener.PerformSaveOrUpdate
> (SaveOrUpdateEvent event)
> at
> NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.OnSaveOrUpdate
> (SaveOrUpdateEvent event)
> at NHibernate.Impl.SessionImpl.FireSave(SaveOrUpdateEvent event)
> at NHibernate.Impl.SessionImpl.Save(Object obj)
> at Rhino.Commons.NHRepository`1.Save(T entity)
> at Rhino.Commons.Repository`1.Save(T entity)
> at TuhDoo.Core.Tests.Domain.TaskTest.Creation() in D:\...@repository
> \TuhDoo\src\TuhDoo.Core.Tests\Domain\TaskTest.cs:line 30
>
> ********************************************************************************************
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Rhino Tools Dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rhino-tools-dev?hl=en
-~----------~----~----~----~------~----~------~--~---