From: <fab...@us...> - 2009-10-18 20:51:12
|
Revision: 4791 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4791&view=rev Author: fabiomaulo Date: 2009-10-18 20:51:03 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Minor (cleaned to be back ported) Modified Paths: -------------- 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 Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/DummyEntity.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/DummyEntity.cs 2009-10-18 20:37:46 UTC (rev 4790) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/DummyEntity.cs 2009-10-18 20:51:03 UTC (rev 4791) @@ -1,24 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NHibernate.Test.NHSpecificTest.NH1969 +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; } - } - - } -} + /// <summary> + /// Author : Stephane Verlet + /// </summary> + public class DummyEntity + { + public int Id { get; set; } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/EntityWithTypeProperty.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/EntityWithTypeProperty.cs 2009-10-18 20:37:46 UTC (rev 4790) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/EntityWithTypeProperty.cs 2009-10-18 20:51:03 UTC (rev 4791) @@ -1,35 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NHibernate.Test.NHSpecificTest.NH1969 +namespace NHibernate.Test.NHSpecificTest.NH1969 { - /// <summary> - /// Author : Stephane Verlet - /// </summary> - public class EntityWithTypeProperty - { + /// <summary> + /// Author : Stephane Verlet + /// </summary> + public class EntityWithTypeProperty + { + public int Id { get; set; } - 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; } - } - - } -} + public System.Type TypeValue { get; set; } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/Fixture.cs 2009-10-18 20:37:46 UTC (rev 4790) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/Fixture.cs 2009-10-18 20:51:03 UTC (rev 4791) @@ -1,91 +1,79 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; +using System.IO; +using NHibernate.Criterion; 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()) { + using (ITransaction tx = s.BeginTransaction()) + { + var entity = new EntityWithTypeProperty {Id = 1, TypeValue = typeof (File)}; + s.Save(entity); - EntityWithTypeProperty entity = new EntityWithTypeProperty(); - entity.Id = 1; - entity.TypeValue = typeof(System.IO.File); //A random not mapped type - s.Save(entity); + entity = new EntityWithTypeProperty {Id = 2, TypeValue = typeof (DummyEntity)}; + s.Save(entity); - entity = new EntityWithTypeProperty(); - entity.Id = 2; - entity.TypeValue = typeof(DummyEntity); // A mapped entity - s.Save(entity); - - tx.Commit(); + tx.Commit(); + } } - } protected override void OnTearDown() { - using (ISession session = this.OpenSession()) - using (ITransaction tx = session.BeginTransaction()) + using (ISession session = OpenSession()) { - string hql = "from System.Object"; - session.Delete(hql); - tx.Commit(); + using (ITransaction tx = session.BeginTransaction()) + { + session.CreateQuery("delete from DummyEntity").ExecuteUpdate(); + session.CreateQuery("delete from EntityWithTypeProperty").ExecuteUpdate(); + tx.Commit(); + } } } - [Test,Ignore] + [Test, Ignore] public void TestMappedTypeCriteria() { using (ISession s = OpenSession()) { - ICriteria criteria = s.CreateCriteria(typeof(EntityWithTypeProperty)); - criteria.Add(Restrictions.Eq("TypeValue", typeof(DummyEntity))); + 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)); + 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))); + ICriteria criteria = s.CreateCriteria(typeof (EntityWithTypeProperty)); + criteria.Add(Restrictions.Eq("TypeValue", typeof (File))); IList<EntityWithTypeProperty> results = criteria.List<EntityWithTypeProperty>(); Assert.AreEqual(1, results.Count); Assert.AreEqual(1, results[0].Id); @@ -97,15 +85,12 @@ { 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)); + q.SetParameter("type", typeof (File)); IList<EntityWithTypeProperty> results = q.List<EntityWithTypeProperty>(); Assert.AreEqual(1, results.Count); Assert.AreEqual(1, results[0].Id); - } } - } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/Mappings.hbm.xml 2009-10-18 20:37:46 UTC (rev 4790) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/Mappings.hbm.xml 2009-10-18 20:51:03 UTC (rev 4791) @@ -1,25 +1,21 @@ -<?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> +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.NHSpecificTest.NH1969" + assembly="NHibernate.Test" + default-lazy="false"> + + <class name="EntityWithTypeProperty"> + <id name="Id" column="id"> + <generator class="assigned" /> + </id> - <property name="TypeValue" column="typeValue" /> - </class> + <property name="TypeValue" column="typeValue" /> + </class> - <class - name="NHibernate.Test.NHSpecificTest.NH1969.DummyEntity, NHibernate.Test" - table="DummyEntity"> + <class name="DummyEntity"> + <id name="Id" column="id"> + <generator class="assigned" /> + </id> + </class> - <id name="Id" column="id"> - <generator class="assigned" /> - </id> - - - </class> - - </hibernate-mapping> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |