Hello,
I don't want to skip all the important info gathering below, but I am sure I'm just missing something elemental.
I have been working with the examples project from NHibernate-2.0.0.Alpha1-src.zip and modifying for my own purposes to see how it works.
I have some unit tests set up using MbUnit within the NHibernate.Examples-2.0 project using my new tables and mappings, so I think the code and .xml files are correct. Data inserts, updates, etc all work as i would expect them to.
Now, when I tried to move my test fixtures from within the NHibernate.Examples-2.0 project into a new test project, I am receiving an error on trying to run my unit tests in a new project which references the examples project.
Hibernate version:
2.0.0
Mapping documents:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="NHibernate.Examples.QuickStart.Giftcard, NHibernate.Examples" table="giftcard"
lazy="false">
<id name="Id" unsaved-value="0">
<generator class="native" />
</id>
<property name="Name"/>
<property name="Message"/>
<property name="Number"/>
<property name="SecurityCode" column="security_code"/>
<property name="Salt"/>
<property name="StatusId" column="status_id"/>
<property name="InitialAmount" column="initial_amount"/>
<property name="Balance"/>
<property name="AmountCommitted" column="amount_committed"/>
<property name="AvailableBalance" column="available_balance"/>
<property name="BuyerAddressId" column="buyer_address_id"/>
<property name="RecipientAddressId" column="recipient_address_id"/>
<property name="DateCreated" column="date_created" not-null="true" insert="false" update="false"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():code in new test project which calls the object method in the DAL project:
Code:
[TestFixture]
public class GiftCardFixture
{
[Test, RollBack]
public void GiftcardAdd()
{
Giftcard newGiftcard = new Giftcard();
newGiftcard.Name = "test card";
newGiftcard.Message = "test message";
newGiftcard.Number = "1234567890123456";
newGiftcard.SecurityCode = "123456";
newGiftcard.Salt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
newGiftcard.StatusId = 1;
newGiftcard.InitialAmount = 500;
newGiftcard.Balance = 500;
newGiftcard.BuyerAddressId = 1;
newGiftcard.RecipientAddressId = 1;
newGiftcard.AmountCommitted = 0;
int generatedId = newGiftcard.Add();
Assert.IsTrue(generatedId > 0);
}
}
code in the DAL project which handles the call from above:
Code:
public int Add()
{
Configuration cfg = new Configuration();
cfg.AddAssembly("NHibernate.Examples");
ISessionFactory factory = cfg.BuildSessionFactory();
ISession session = factory.OpenSession();
ITransaction transaction = session.BeginTransaction();
// Tell NHibernate that this object should be saved
int generatedId = (int)session.Save(this);
// commit all of the changes to the DB and close the ISession
transaction.Commit();
session.Close();
return generatedId;
}
it is choking on the
Code:
cfg.AddAssembly("NHibernate.Examples");
line.
Full stack trace of any exception that occurs:Code:
Message: Could not compile the mapping document: NHibernate.Examples.GiftCardTransaction.GiftcardTransaction.hbm.xml
Type: NHibernate.MappingException
Source: NHibernate
TargetSite: Void LogAndThrow(System.Exception)
HelpLink: null
Stack: at NHibernate.Cfg.Configuration.LogAndThrow(Exception exception)
at NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc)
at NHibernate.Cfg.Configuration.ProcessMappingsQueue()
at NHibernate.Cfg.Configuration.AddDocumentThroughQueue(NamedXmlDocument document)
at NHibernate.Cfg.Configuration.AddXmlReader(XmlReader hbmReader, String name)
at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream, String name)
at NHibernate.Cfg.Configuration.AddResource(String path, Assembly assembly)
at NHibernate.Cfg.Configuration.AddAssembly(Assembly assembly)
at NHibernate.Cfg.Configuration.AddAssembly(String assemblyName)
at NHibernate.Examples.QuickStart.Giftcard.Add() in C:\Documents and Settings\mcomroe\My Documents\Visual Studio 2005\Projects\GiftCardDAL\GiftCardDAL\GiftCard\Giftcard.cs:line 119
at eDevix.GiftCardDALTests.GiftCardFixture.GiftcardAdd() in C:\Documents and Settings\mcomroe\My Documents\Visual Studio 2005\Projects\GiftCardDAL\GiftCardDALTests\GiftCardfixture.cs:line 27
The only references in the test project are to MbUnit.Framework and a project reference to the DAL project so I can get at those objects.
I guess the important thing to keep in mind is that my tests run fine when they are within the DAL project, and just not when they are in the separate test project.
I'm sure the problem is between the user and keyboard, but any help would be greatly appreciated.
Thanks in advance.