From: <ste...@us...> - 2009-05-14 11:43:21
|
Revision: 4300 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4300&view=rev Author: steverstrong Date: 2009-05-14 11:43:14 +0000 (Thu, 14 May 2009) Log Message: ----------- Added test for NH-1773 Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Domain.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Person.hbm.xml Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Domain.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Domain.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Domain.cs 2009-05-14 11:43:14 UTC (rev 4300) @@ -0,0 +1,80 @@ +using System; + +namespace NHibernate.Test.NHSpecificTest.NH1773 +{ + public class Person + { + private string _name; + private int _age; + private int _id; + private Country _country; + + public virtual int Id + { + get { return _id; } + set { _id = value; } + } + + public virtual string Name + { + get { return _name; } + set { _name = value; } + } + + public virtual int Age + { + get { return _age; } + set { _age = value; } + } + + public virtual Country Country + { + get { return _country; } + set { _country = value; } + } + } + + public class Country + { + private int _id; + private string _name; + + public virtual int Id + { + get { return _id; } + set { _id = value; } + } + + public virtual string Name + { + get { return _name; } + set { _name = value; } + } + } + + public class PersonResult + { + private Person _person; + private DateTime _time; + + public PersonResult(Person x) + { + } + + public PersonResult(Person person, DateTime time) + { + _person = person; + _time = time; + } + + public Person Person + { + get { return _person; } + } + + public DateTime Time + { + get { return _time; } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Fixture.cs 2009-05-14 11:43:14 UTC (rev 4300) @@ -0,0 +1,63 @@ +using System; +using System.Collections; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1773 +{ + [TestFixture] + public class Fixture : BugTestCase + { + protected override void Configure(NHibernate.Cfg.Configuration configuration) + { + base.Configure(configuration); + //configuration.SetProperty(NHibernate.Cfg.Environment.QueryTranslator, typeof(NHibernate.Hql.Classic.ClassicQueryTranslatorFactory).AssemblyQualifiedName); + } + + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + protected override IList Mappings + { + get { return new[] { "NHSpecificTest.NH1773.Person.hbm.xml"}; } + } + + [Test] + public void CustomHQLFunctionsShouldBeRecognizedByTheParser() + { + using (ISession s = OpenSession()) + { + using (ITransaction tx = s.BeginTransaction()) + { + Country c = new Country() {Id = 100, Name = "US"}; + Person p = new Person() {Age = 35, Name = "My Name", Id=1, Country = c}; + s.Save(c); + s.Save(p); + tx.Commit(); + } + } + + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + IList result = s.CreateQuery("select new PersonResult(p, current_timestamp()) from Person p left join fetch p.Country").List(); + + Assert.AreEqual("My Name", ((PersonResult)result[0]).Person.Name); + Assert.IsTrue(NHibernateUtil.IsInitialized(((PersonResult)result[0]).Person.Country)); + tx.Commit(); + } + } + + protected override void OnTearDown() + { + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.Delete("from Person"); + s.Delete("from Country"); + tx.Commit(); + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Person.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Person.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1773/Person.hbm.xml 2009-05-14 11:43:14 UTC (rev 4300) @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1773"> + <import class="PersonResult" /> + <class name="Person" table="Person"> + <id name="Id" column="id" unsaved-value="0"> + <generator class="assigned" /> + </id> + <property name="Name" column="Name" /> + <property name="Age" column="Age" /> + <many-to-one name="Country" class="Country" column="CountryId" /> + </class> + + <class name="Country" table="Country"> + <id name="Id" column="Id" unsaved-value="0"> + <generator class="assigned" /> + </id> + <property name="Name" column="Name" /> + </class> +</hibernate-mapping> \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-14 11:35:34 UTC (rev 4299) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-14 11:43:14 UTC (rev 4300) @@ -381,6 +381,8 @@ <Compile Include="NHSpecificTest\NH1742\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1760\DomainClass.cs" /> <Compile Include="NHSpecificTest\NH1760\SampleTest.cs" /> + <Compile Include="NHSpecificTest\NH1773\Domain.cs" /> + <Compile Include="NHSpecificTest\NH1773\Fixture.cs" /> <Compile Include="NHSpecificTest\NH645\HQLFunctionFixture.cs" /> <Compile Include="HQL\HQLFunctions.cs" /> <Compile Include="HQL\Human.cs" /> @@ -1773,6 +1775,7 @@ <EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" /> <EmbeddedResource Include="Ado\VerySimple.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1773\Person.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1760\Mappings.hbm.xml" /> <EmbeddedResource Include="MappingTest\Wicked.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1393\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |