Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/MappingExceptions
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16129/NHibernate.Test/MappingExceptions
Added Files:
MissingDefCtor.cs MissingDefCtor.hbm.xml
MissingDefCtorFixture.cs
Log Message:
Added a fixture to verify the exception thrown when a class is missing
a default ctor is easy to read.
--- NEW FILE: MissingDefCtor.hbm.xml ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: MissingDefCtor.cs ---
using System;
namespace NHibernate.Test.MappingExceptions
{
/// <summary>
/// Summary description for MissingDefCtor.
/// </summary>
public class MissingDefCtor
{
private int _id;
private string _something;
public MissingDefCtor(string something)
{
_something = something;
}
public int Id
{
get { return _id; }
set { _id = value; }
}
public string Something
{
get { return _something; }
set { _something = value; }
}
}
}
--- NEW FILE: MissingDefCtorFixture.cs ---
using System;
using NHibernate.Cfg;
using NUnit.Framework;
namespace NHibernate.Test.MappingExceptions
{
/// <summary>
/// A TestFixture to verify the Exception thrown when a mapped class is missing the default
/// ctor is readable and understandable.
/// </summary>
[TestFixture]
public class MissingDefCtorFixture
{
[Test]
public void ClassMissingDefaultCtor()
{
bool excCaught = false;
// add a resource that doesn't exist
string resource = "NHibernate.Test.MappingExceptions.MissingDefCtor.hbm.xml";
Configuration cfg = new Configuration();
try
{
cfg.AddResource( resource, this.GetType().Assembly );
cfg.BuildSessionFactory();
}
catch( MappingException me )
{
Assert.AreEqual( "The mapped class NHibernate.Test.MappingExceptions.MissingDefCtor must declare a default (no-arg) constructor.", me.Message );
excCaught = true;
}
Assert.IsTrue( excCaught, "Should have caught the MappingException about default ctor being missing." );
}
}
}
|