From: <te...@us...> - 2009-09-21 01:58:12
|
Revision: 4719 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4719&view=rev Author: tehlike Date: 2009-09-21 01:57:56 +0000 (Mon, 21 Sep 2009) Log Message: ----------- Adding tests for NH-1969 Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/DummyEntity.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/EntityWithTypeProperty.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/Mappings.hbm.xml Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/DummyEntity.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/DummyEntity.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/DummyEntity.cs 2009-09-21 01:57:56 UTC (rev 4719) @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NHibernate.Test.NHSpecificTest.NH1969 +{ + /// <summary> + /// Author : Stephane Verlet + /// </summary> + public class DummyEntity + { + + private int _id; + + + public int Id + { + get { return _id; } + set { _id = value; } + } + + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/EntityWithTypeProperty.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/EntityWithTypeProperty.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/EntityWithTypeProperty.cs 2009-09-21 01:57:56 UTC (rev 4719) @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NHibernate.Test.NHSpecificTest.NH1969 +{ + /// <summary> + /// Author : Stephane Verlet + /// </summary> + public class EntityWithTypeProperty + { + + private int _id; + private System.Type _typeValue; + + public EntityWithTypeProperty() + { + _id = 0; + } + + public int Id + { + get { return _id; } + set { _id = value; } + } + + public System.Type TypeValue + { + get { return _typeValue; } + set { _typeValue = value; } + } + + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/Fixture.cs 2009-09-21 01:57:56 UTC (rev 4719) @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1969 +{ + using Criterion; + + /// <summary> + /// Author : Stephane Verlet + /// </summary> + [TestFixture] + public class Fixture : BugTestCase + { + + protected override void OnSetUp() + { + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + + EntityWithTypeProperty entity = new EntityWithTypeProperty(); + entity.Id = 1; + entity.TypeValue = typeof(System.IO.File); //A random not mapped type + s.Save(entity); + + entity = new EntityWithTypeProperty(); + entity.Id = 2; + entity.TypeValue = typeof(DummyEntity); // A mapped entity + s.Save(entity); + + tx.Commit(); + } + + } + + protected override void OnTearDown() + { + using (ISession session = this.OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + string hql = "from System.Object"; + session.Delete(hql); + tx.Commit(); + } + } + + [Test,Ignore] + public void TestMappedTypeCriteria() + { + using (ISession s = OpenSession()) + { + ICriteria criteria = s.CreateCriteria(typeof(EntityWithTypeProperty)); + criteria.Add(Restrictions.Eq("TypeValue", typeof(DummyEntity))); + IList<EntityWithTypeProperty> results = criteria.List<EntityWithTypeProperty>(); + Assert.AreEqual(1, results.Count); + Assert.AreEqual(2, results[0].Id); + } + } + + + [Test] + public void TestMappedTypeHQL() + { + using (ISession s = OpenSession()) + { + + IQuery q = s.CreateQuery("select t from EntityWithTypeProperty as t where t.TypeValue = :type"); + q.SetParameter("type", typeof(DummyEntity)); + IList<EntityWithTypeProperty> results = q.List<EntityWithTypeProperty>(); + Assert.AreEqual(1, results.Count); + Assert.AreEqual(2, results[0].Id); + + } + } + + + + + [Test] + public void TestNonMappedTypeCriteria() + { + using (ISession s = OpenSession()) + { + ICriteria criteria = s.CreateCriteria(typeof(EntityWithTypeProperty)); + criteria.Add(Restrictions.Eq("TypeValue", typeof(System.IO.File))); + IList<EntityWithTypeProperty> results = criteria.List<EntityWithTypeProperty>(); + Assert.AreEqual(1, results.Count); + Assert.AreEqual(1, results[0].Id); + } + } + + [Test] + public void TestNonMappedTypeHQL() + { + using (ISession s = OpenSession()) + { + + IQuery q = s.CreateQuery("select t from EntityWithTypeProperty as t where t.TypeValue = :type"); + q.SetParameter("type", typeof(System.IO.File)); + IList<EntityWithTypeProperty> results = q.List<EntityWithTypeProperty>(); + Assert.AreEqual(1, results.Count); + Assert.AreEqual(1, results[0].Id); + + } + } + + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/Mappings.hbm.xml 2009-09-21 01:57:56 UTC (rev 4719) @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false"> + <class + name="NHibernate.Test.NHSpecificTest.NH1969.EntityWithTypeProperty, NHibernate.Test" + table="EntityWithTypeProperty"> + <id name="Id" column="id"> + <generator class="assigned" /> + </id> + + <property name="TypeValue" column="typeValue" /> + </class> + + <class + name="NHibernate.Test.NHSpecificTest.NH1969.DummyEntity, NHibernate.Test" + table="DummyEntity"> + + <id name="Id" column="id"> + <generator class="assigned" /> + </id> + + + </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-09-16 10:53:14 UTC (rev 4718) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-09-21 01:57:56 UTC (rev 4719) @@ -603,6 +603,9 @@ <Compile Include="NHSpecificTest\NH1938\Model.cs" /> <Compile Include="NHSpecificTest\NH1939\AuxType.cs" /> <Compile Include="NHSpecificTest\NH1939\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1969\DummyEntity.cs" /> + <Compile Include="NHSpecificTest\NH1969\EntityWithTypeProperty.cs" /> + <Compile Include="NHSpecificTest\NH1969\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> <Compile Include="NHSpecificTest\NH473\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Parent.cs" /> @@ -2017,6 +2020,7 @@ <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1969\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1922\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\CriteriaQueryOnComponentCollection\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1908ThreadSafety\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |