From: <fab...@us...> - 2009-06-16 02:43:16
|
Revision: 4483 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4483&view=rev Author: fabiomaulo Date: 2009-06-16 02:43:15 +0000 (Tue, 16 Jun 2009) Log Message: ----------- removed unused file (sorry) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Removed Paths: ------------- trunk/nhibernate/src/NHibernate.Test/EngineTest/QueryPlanCacheFixture.cs Deleted: trunk/nhibernate/src/NHibernate.Test/EngineTest/QueryPlanCacheFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/EngineTest/QueryPlanCacheFixture.cs 2009-06-16 02:40:36 UTC (rev 4482) +++ trunk/nhibernate/src/NHibernate.Test/EngineTest/QueryPlanCacheFixture.cs 2009-06-16 02:43:15 UTC (rev 4483) @@ -1,7 +0,0 @@ -namespace NHibernate.Test.EngineTest -{ - public class QueryPlanCacheFixture - { - - } -} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-16 02:40:36 UTC (rev 4482) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-16 02:43:15 UTC (rev 4483) @@ -148,7 +148,6 @@ <Compile Include="Criteria\ProjectionsTest.cs" /> <Compile Include="Criteria\Reptile.cs" /> <Compile Include="DriverTest\SqlClientDriverFixture.cs" /> - <Compile Include="EngineTest\QueryPlanCacheFixture.cs" /> <Compile Include="ExpressionTest\RestrictionsFixture.cs" /> <Compile Include="Criteria\Student.cs" /> <Compile Include="Criteria\StudentDTO.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <te...@us...> - 2009-06-20 16:09:57
|
Revision: 4495 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4495&view=rev Author: tehlike Date: 2009-06-20 16:09:53 +0000 (Sat, 20 Jun 2009) Log Message: ----------- Adding test to show NH-473 is not an issue (should have been fixed somewhere in the past) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH473/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH473/Child.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH473/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH473/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH473/Parent.cs Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH473/Child.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH473/Child.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH473/Child.cs 2009-06-20 16:09:53 UTC (rev 4495) @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NHibernate.Test.NHSpecificTest.NH473 +{ + public class Child + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH473/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH473/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH473/Fixture.cs 2009-06-20 16:09:53 UTC (rev 4495) @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Text; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH473 +{ + [TestFixture] + public class Fixture:BugTestCase + { + protected override void OnSetUp() + { + using(var session=this.OpenSession()) + using(var tran=session.BeginTransaction()) + { + var parent = new Parent(); + var child1 = new Child {Name = "Fabio"}; + var child2 = new Child {Name = "Ayende"}; + var child3 = new Child {Name = "Dario"}; + parent.Children.Add(child1); + parent.Children.Add(child2); + parent.Children.Add(child3); + session.Save(parent); + tran.Commit(); + } + } + protected override void OnTearDown() + { + using (var session = this.OpenSession()) + using (var tran = session.BeginTransaction()) + { + session.Delete("from Parent"); + tran.Commit(); + } + } + [Test] + public void ChildItemsGetInOrderWhenUsingFetchJoin() + { + using(var session=this.OpenSession()) + using(var tran=session.BeginTransaction()) + { + var result = session.CreateCriteria(typeof (Parent)) + .SetFetchMode("Children", FetchMode.Join) + .List<Parent>(); + Assert.That(result[0].Children[0].Name,Is.EqualTo("Ayende")); + Assert.That(result[0].Children[1].Name, Is.EqualTo("Dario")); + Assert.That(result[0].Children[2].Name, Is.EqualTo("Fabio")); + } + } + + [Test] + public void ChildItemsGetInOrderWhenUsingFetchJoinUniqueResult() + { + using (var session = this.OpenSession()) + using (var tran = session.BeginTransaction()) + { + var result = session.CreateCriteria(typeof(Parent)) + .SetFetchMode("Children", FetchMode.Join) + .UniqueResult<Parent>(); + Assert.That(result.Children[0].Name, Is.EqualTo("Ayende")); + Assert.That(result.Children[1].Name, Is.EqualTo("Dario")); + Assert.That(result.Children[2].Name, Is.EqualTo("Fabio")); + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH473/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH473/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH473/Mappings.hbm.xml 2009-06-20 16:09:53 UTC (rev 4495) @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH473"> + + <class name="Parent"> + <id name="Id"> + <generator class="native"/> + </id> + + <bag name="Children" lazy="true" order-by="Name" cascade="all-delete-orphan"> + <key column="ParentId" /> + <one-to-many class="Child" /> + </bag> + </class> + + <class name="Child"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="Name"/> + </class> +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH473/Parent.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH473/Parent.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH473/Parent.cs 2009-06-20 16:09:53 UTC (rev 4495) @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Iesi.Collections; +using Iesi.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH473 +{ + public class Parent + { + public Parent() + { + this.Children = new List<Child>(); + } + public virtual int Id { get; set; } + public virtual IList<Child> Children { get; set; } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-20 15:21:09 UTC (rev 4494) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-20 16:09:53 UTC (rev 4495) @@ -515,6 +515,9 @@ <Compile Include="NHSpecificTest\NH1837\Customer.cs" /> <Compile Include="NHSpecificTest\NH1837\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1837\Order.cs" /> + <Compile Include="NHSpecificTest\NH473\Child.cs" /> + <Compile Include="NHSpecificTest\NH473\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH473\Parent.cs" /> <Compile Include="NHSpecificTest\NH645\HQLFunctionFixture.cs" /> <Compile Include="HQL\HQLFunctions.cs" /> <Compile Include="HQL\Human.cs" /> @@ -1922,6 +1925,7 @@ <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH473\Mappings.hbm.xml" /> <EmbeddedResource Include="VersionTest\Db\User.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1831\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1069\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <te...@us...> - 2009-06-20 18:40:46
|
Revision: 4496 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4496&view=rev Author: tehlike Date: 2009-06-20 18:40:44 +0000 (Sat, 20 Jun 2009) Log Message: ----------- Adding tests to show that NH-1097 is no longer an issue Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1097/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1097/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1097/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1097/Person.cs Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1097/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1097/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1097/Fixture.cs 2009-06-20 18:40:44 UTC (rev 4496) @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Text; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1097 +{ + [TestFixture] + public class Fixture:BugTestCase + { + protected override void OnSetUp() + { + using(var session=this.OpenSession()) + using(var tran=session.BeginTransaction()) + { + session.Save(new Person {Name = "Fabio"}); + session.Save(new Person { Name = "Dario" }); + tran.Commit(); + } + } + protected override void OnTearDown() + { + using (var session = this.OpenSession()) + using (var tran = session.BeginTransaction()) + { + session.Save(new Person { Name = "Fabio" }); + session.Save(new Person { Name = "Dario" }); + session.Delete("from Person"); + tran.Commit(); + } + } + + [Test] + public void ThrowsExceptionWhenColumnNameIsUsedInQuery() + { + using (var session = this.OpenSession()) + using (var tran = session.BeginTransaction()) + { + + Assert.Throws<QueryException>(delegate + { + var query = session.CreateQuery("from Person p where p.namecolumn=:nameOfPerson"); + query.SetString("nameOfPerson", "Dario"); + query.List(); + }); + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1097/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1097/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1097/Mappings.hbm.xml 2009-06-20 18:40:44 UTC (rev 4496) @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1097"> + <class name="Person"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="Name" column="namecolumn"/> + </class> +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1097/Person.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1097/Person.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1097/Person.cs 2009-06-20 18:40:44 UTC (rev 4496) @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NHibernate.Test.NHSpecificTest.NH1097 +{ + public class Person + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-20 16:09:53 UTC (rev 4495) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-20 18:40:44 UTC (rev 4496) @@ -362,6 +362,8 @@ <Compile Include="NHSpecificTest\NH1092\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1093\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1093\SimpleCached.cs" /> + <Compile Include="NHSpecificTest\NH1097\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1097\Person.cs" /> <Compile Include="NHSpecificTest\NH1159\Contact.cs" /> <Compile Include="NHSpecificTest\NH1159\ContactTitle.cs" /> <Compile Include="NHSpecificTest\NH1159\Fixture.cs" /> @@ -1925,6 +1927,7 @@ <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1097\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH473\Mappings.hbm.xml" /> <EmbeddedResource Include="VersionTest\Db\User.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1831\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <te...@us...> - 2009-06-20 19:24:39
|
Revision: 4497 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4497&view=rev Author: tehlike Date: 2009-06-20 19:24:32 +0000 (Sat, 20 Jun 2009) Log Message: ----------- Adding tests to show NH-1734 is no longer an issue. Possibly fixed with new AST parser. Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1734/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1734/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1734/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1734/Product.cs Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1734/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1734/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1734/Fixture.cs 2009-06-20 19:24:32 UTC (rev 4497) @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Text; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1734 +{ + [TestFixture] + public class Fixture:BugTestCase + { + protected override void OnSetUp() + { + using(var session=this.OpenSession()) + using(var tran=session.BeginTransaction()) + { + var product = new Product {Amount = 3, Price = 43.2}; + var product2 = new Product { Amount = 3, Price = 43.2 }; + session.Save(product); + session.Save(product2); + tran.Commit(); + } + } + protected override void OnTearDown() + { + using(var session=this.OpenSession()) + using (var tran = session.BeginTransaction()) + { + session.Delete("from Product"); + tran.Commit(); + } + } + + [Test] + public void ReturnsApropriateTypeWhenSumUsedWithSomeFormula() + { + using (var session = this.OpenSession()) + using (var tran = session.BeginTransaction()) + { + var query=session.CreateQuery("select sum(Amount*Price) from Product"); + var result=query.UniqueResult(); + Assert.That(result, Is.InstanceOf(typeof (double))); + Assert.That(result, Is.EqualTo(43.2*3*2)); + query = session.CreateQuery("select sum(Price*Amount) from Product"); + result = query.UniqueResult(); + Assert.That(result, Is.InstanceOf(typeof(double))); + Assert.That(result, Is.EqualTo(43.2 * 3 * 2)); + + query = session.CreateQuery("select sum(Price) from Product"); + result = query.UniqueResult(); + Assert.That(result, Is.InstanceOf(typeof(double))); + Assert.That(result, Is.EqualTo(43.2 * 2)); + + query = session.CreateQuery("select sum(Amount) from Product"); + result = query.UniqueResult(); + Assert.That(result, Is.InstanceOf(typeof(Int64))); + Assert.That(result, Is.EqualTo(6.0)); + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1734/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1734/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1734/Mappings.hbm.xml 2009-06-20 19:24:32 UTC (rev 4497) @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.NHSpecificTest.NH1734" + assembly="NHibernate.Test"> + <class name="Product"> + <id name="Id"> + <generator class="native"/> + </id> + <property name="Price"/> + <property name="Amount" /> + </class> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1734/Product.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1734/Product.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1734/Product.cs 2009-06-20 19:24:32 UTC (rev 4497) @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NHibernate.Test.NHSpecificTest.NH1734 +{ + public class Product + { + public virtual int Id { get; set; } + public virtual double Price { get; set; } + public virtual int Amount { get; set; } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-20 18:40:44 UTC (rev 4496) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-20 19:24:32 UTC (rev 4497) @@ -457,6 +457,8 @@ <Compile Include="NHSpecificTest\NH1716\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1727\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1727\Model.cs" /> + <Compile Include="NHSpecificTest\NH1734\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1734\Product.cs" /> <Compile Include="NHSpecificTest\NH1741\Domain.cs" /> <Compile Include="NHSpecificTest\NH1741\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1742\DomainClass.cs" /> @@ -1927,6 +1929,7 @@ <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1734\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1097\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH473\Mappings.hbm.xml" /> <EmbeddedResource Include="VersionTest\Db\User.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <te...@us...> - 2009-06-21 08:17:16
|
Revision: 4498 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4498&view=rev Author: tehlike Date: 2009-06-21 08:17:14 +0000 (Sun, 21 Jun 2009) Log Message: ----------- Adding tests for NH-1192 showing it is no longer an issue. Should have been fixed with the new AST parser. Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1192/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1192/Domain.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1192/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1192/Mappings.hbm.xml Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1192/Domain.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1192/Domain.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1192/Domain.cs 2009-06-21 08:17:14 UTC (rev 4498) @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NHibernate.Test.NHSpecificTest.NH1192 +{ + public enum Status + { + None, + Bold=1, + Italic=2, + Underlined=4 + + } + public class ObjectA + { + public virtual int Id { get; set; } + public virtual Status FontType { get; set; } + public virtual string Name { get; set; } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1192/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1192/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1192/Fixture.cs 2009-06-21 08:17:14 UTC (rev 4498) @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Text; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1192 +{ + [TestFixture] + public class Fixture:BugTestCase + { + protected override void OnSetUp() + { + using(var session=this.OpenSession()) + using(var tran=session.BeginTransaction()) + { + session.Save(new ObjectA {FontType = Status.Bold|Status.Italic, Name = "Object1"}); + session.Save(new ObjectA { FontType = Status.Italic, Name = "Object2" }); + session.Save(new ObjectA { FontType = Status.Underlined, Name = "Object2" }); + tran.Commit(); + } + } + protected override void OnTearDown() + { + using (var session = this.OpenSession()) + using (var tran = session.BeginTransaction()) + { + session.Delete("from ObjectA"); + tran.Commit(); + } + } + + [Test] + public void BitwiseAndWorksCorrectly() + { + using (var session = this.OpenSession()) + using (var tran = session.BeginTransaction()) + { + var query = session.CreateQuery("from ObjectA o where (o.FontType & 1) > 0"); + var result = query.List(); + Assert.That(result,Has.Count.EqualTo(1)); + query = session.CreateQuery("from ObjectA o where (o.FontType & 2) > 0"); + result = query.List(); + Assert.That(result, Has.Count.EqualTo(2)); + + query = session.CreateQuery("from ObjectA o where (o.FontType & 4) > 0"); + result = query.List(); + Assert.That(result, Has.Count.EqualTo(1)); + } + } + + [Test] + public void BitwiseOrWorksCorrectly() + { + using (var session = this.OpenSession()) + using (var tran = session.BeginTransaction()) + { + var query = session.CreateQuery("from ObjectA o where (o.FontType | 2) = (1|2) "); + var result = query.List(); + Assert.That(result, Has.Count.EqualTo(1)); + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1192/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1192/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1192/Mappings.hbm.xml 2009-06-21 08:17:14 UTC (rev 4498) @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.NHSpecificTest.NH1192" + assembly="NHibernate.Test"> + + <class name="ObjectA"> + <id name="Id"> + <generator class="native"/> + </id> + <property name="Name"/> + <property name="FontType"/> + + </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-06-20 19:24:32 UTC (rev 4497) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-21 08:17:14 UTC (rev 4498) @@ -372,6 +372,8 @@ <Compile Include="NHSpecificTest\NH1171\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1182\Domain.cs" /> <Compile Include="NHSpecificTest\NH1182\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1192\Domain.cs" /> + <Compile Include="NHSpecificTest\NH1192\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1264\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1264\Name.cs" /> <Compile Include="NHSpecificTest\NH1264\Passenger.cs" /> @@ -1929,6 +1931,7 @@ <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1192\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1734\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1097\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH473\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ric...@us...> - 2009-06-23 17:33:56
|
Revision: 4517 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4517&view=rev Author: RicBrown Date: 2009-06-23 17:33:55 +0000 (Tue, 23 Jun 2009) Log Message: ----------- Replaced session stub with methods in fixture base. Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaFixture.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Removed Paths: ------------- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/SessionStub.cs Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaFixture.cs 2009-06-23 17:25:23 UTC (rev 4516) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaFixture.cs 2009-06-23 17:33:55 UTC (rev 4517) @@ -18,12 +18,12 @@ [Test] public void Equality() { - ICriteria expected = CreateSession() - .CreateCriteria(typeof(Person)) + ICriteria expected = + CreateTestCriteria(typeof(Person)) .Add(Restrictions.Eq("Name", "test name")); - ICriteria actual = CreateSession() - .CreateCriteria(typeof(Person)) + ICriteria actual = + CreateTestCriteria(typeof(Person)) .Add<Person>(p => p.Name == "test name"); AssertCriteriaAreEqual(expected, actual); Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs 2009-06-23 17:25:23 UTC (rev 4516) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs 2009-06-23 17:33:55 UTC (rev 4517) @@ -19,11 +19,16 @@ private Hashtable _visitedObjects = new Hashtable(); private Stack<string> _fieldPath = new Stack<string>(); - protected ISession CreateSession() + protected ICriteria CreateTestCriteria(System.Type persistentClass) { - return new SessionStub(); + return new CriteriaImpl(persistentClass, null); } + protected ICriteria CreateTestCriteria(System.Type persistentClass, string alias) + { + return new CriteriaImpl(persistentClass, alias, null); + } + private void AssertDictionariesAreEqual(IDictionary expected, IDictionary actual) { Assert.AreEqual(expected.Keys.Count, actual.Keys.Count, _fieldPath.Peek() + ".Count"); Deleted: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/SessionStub.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/SessionStub.cs 2009-06-23 17:25:23 UTC (rev 4516) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/SessionStub.cs 2009-06-23 17:33:55 UTC (rev 4517) @@ -1,489 +0,0 @@ - -using System; -using System.Collections.Generic; - -using NHibernate.Impl; - -namespace NHibernate.Test.Criteria.Lambda -{ - - public class SessionStub : ISession - { - - ICriteria ISession.CreateCriteria(System.Type persistentClass) - { - return new CriteriaImpl(persistentClass, null); - } - - ICriteria ISession.CreateCriteria(System.Type persistentClass, string alias) - { - return new CriteriaImpl(persistentClass, alias, null); - } - - #region non stubbed methods - - EntityMode ISession.ActiveEntityMode - { - get { throw new NotImplementedException(); } - } - - void ISession.Flush() - { - throw new NotImplementedException(); - } - - FlushMode ISession.FlushMode - { - get - { - throw new NotImplementedException(); - } - set - { - throw new NotImplementedException(); - } - } - - CacheMode ISession.CacheMode - { - get - { - throw new NotImplementedException(); - } - set - { - throw new NotImplementedException(); - } - } - - ISessionFactory ISession.SessionFactory - { - get { throw new NotImplementedException(); } - } - - System.Data.IDbConnection ISession.Connection - { - get { throw new NotImplementedException(); } - } - - System.Data.IDbConnection ISession.Disconnect() - { - throw new NotImplementedException(); - } - - void ISession.Reconnect() - { - throw new NotImplementedException(); - } - - void ISession.Reconnect(System.Data.IDbConnection connection) - { - throw new NotImplementedException(); - } - - System.Data.IDbConnection ISession.Close() - { - throw new NotImplementedException(); - } - - void ISession.CancelQuery() - { - throw new NotImplementedException(); - } - - bool ISession.IsOpen - { - get { throw new NotImplementedException(); } - } - - bool ISession.IsConnected - { - get { throw new NotImplementedException(); } - } - - bool ISession.IsDirty() - { - throw new NotImplementedException(); - } - - object ISession.GetIdentifier(object obj) - { - throw new NotImplementedException(); - } - - bool ISession.Contains(object obj) - { - throw new NotImplementedException(); - } - - void ISession.Evict(object obj) - { - throw new NotImplementedException(); - } - - object ISession.Load(System.Type theType, object id, LockMode lockMode) - { - throw new NotImplementedException(); - } - - object ISession.Load(string entityName, object id, LockMode lockMode) - { - throw new NotImplementedException(); - } - - object ISession.Load(System.Type theType, object id) - { - throw new NotImplementedException(); - } - - T ISession.Load<T>(object id, LockMode lockMode) - { - throw new NotImplementedException(); - } - - T ISession.Load<T>(object id) - { - throw new NotImplementedException(); - } - - object ISession.Load(string entityName, object id) - { - throw new NotImplementedException(); - } - - void ISession.Load(object obj, object id) - { - throw new NotImplementedException(); - } - - void ISession.Replicate(object obj, ReplicationMode replicationMode) - { - throw new NotImplementedException(); - } - - void ISession.Replicate(string entityName, object obj, ReplicationMode replicationMode) - { - throw new NotImplementedException(); - } - - object ISession.Save(object obj) - { - throw new NotImplementedException(); - } - - void ISession.Save(object obj, object id) - { - throw new NotImplementedException(); - } - - object ISession.Save(string entityName, object obj) - { - throw new NotImplementedException(); - } - - void ISession.SaveOrUpdate(object obj) - { - throw new NotImplementedException(); - } - - void ISession.SaveOrUpdate(string entityName, object obj) - { - throw new NotImplementedException(); - } - - void ISession.Update(object obj) - { - throw new NotImplementedException(); - } - - void ISession.Update(object obj, object id) - { - throw new NotImplementedException(); - } - - void ISession.Update(string entityName, object obj) - { - throw new NotImplementedException(); - } - - object ISession.Merge(object obj) - { - throw new NotImplementedException(); - } - - object ISession.Merge(string entityName, object obj) - { - throw new NotImplementedException(); - } - - void ISession.Persist(object obj) - { - throw new NotImplementedException(); - } - - void ISession.Persist(string entityName, object obj) - { - throw new NotImplementedException(); - } - - object ISession.SaveOrUpdateCopy(object obj) - { - throw new NotImplementedException(); - } - - object ISession.SaveOrUpdateCopy(object obj, object id) - { - throw new NotImplementedException(); - } - - void ISession.Delete(object obj) - { - throw new NotImplementedException(); - } - - void ISession.Delete(string entityName, object obj) - { - throw new NotImplementedException(); - } - - System.Collections.IList ISession.Find(string query) - { - throw new NotImplementedException(); - } - - System.Collections.IList ISession.Find(string query, object value, NHibernate.Type.IType type) - { - throw new NotImplementedException(); - } - - System.Collections.IList ISession.Find(string query, object[] values, NHibernate.Type.IType[] types) - { - throw new NotImplementedException(); - } - - System.Collections.IEnumerable ISession.Enumerable(string query) - { - throw new NotImplementedException(); - } - - System.Collections.IEnumerable ISession.Enumerable(string query, object value, NHibernate.Type.IType type) - { - throw new NotImplementedException(); - } - - System.Collections.IEnumerable ISession.Enumerable(string query, object[] values, NHibernate.Type.IType[] types) - { - throw new NotImplementedException(); - } - - System.Collections.ICollection ISession.Filter(object collection, string filter) - { - throw new NotImplementedException(); - } - - System.Collections.ICollection ISession.Filter(object collection, string filter, object value, NHibernate.Type.IType type) - { - throw new NotImplementedException(); - } - - System.Collections.ICollection ISession.Filter(object collection, string filter, object[] values, NHibernate.Type.IType[] types) - { - throw new NotImplementedException(); - } - - int ISession.Delete(string query) - { - throw new NotImplementedException(); - } - - int ISession.Delete(string query, object value, NHibernate.Type.IType type) - { - throw new NotImplementedException(); - } - - int ISession.Delete(string query, object[] values, NHibernate.Type.IType[] types) - { - throw new NotImplementedException(); - } - - void ISession.Lock(object obj, LockMode lockMode) - { - throw new NotImplementedException(); - } - - void ISession.Lock(string entityName, object obj, LockMode lockMode) - { - throw new NotImplementedException(); - } - - void ISession.Refresh(object obj) - { - throw new NotImplementedException(); - } - - void ISession.Refresh(object obj, LockMode lockMode) - { - throw new NotImplementedException(); - } - - LockMode ISession.GetCurrentLockMode(object obj) - { - throw new NotImplementedException(); - } - - ITransaction ISession.BeginTransaction() - { - throw new NotImplementedException(); - } - - ITransaction ISession.BeginTransaction(System.Data.IsolationLevel isolationLevel) - { - throw new NotImplementedException(); - } - - ITransaction ISession.Transaction - { - get { throw new NotImplementedException(); } - } - - ICriteria ISession.CreateCriteria<T>() - { - throw new NotImplementedException(); - } - - ICriteria ISession.CreateCriteria<T>(string alias) - { - throw new NotImplementedException(); - } - - ICriteria ISession.CreateCriteria(string entityName) - { - throw new NotImplementedException(); - } - - ICriteria ISession.CreateCriteria(string entityName, string alias) - { - throw new NotImplementedException(); - } - - IQuery ISession.CreateQuery(string queryString) - { - throw new NotImplementedException(); - } - - IQuery ISession.CreateFilter(object collection, string queryString) - { - throw new NotImplementedException(); - } - - IQuery ISession.GetNamedQuery(string queryName) - { - throw new NotImplementedException(); - } - - IQuery ISession.CreateSQLQuery(string sql, string returnAlias, System.Type returnClass) - { - throw new NotImplementedException(); - } - - IQuery ISession.CreateSQLQuery(string sql, string[] returnAliases, System.Type[] returnClasses) - { - throw new NotImplementedException(); - } - - ISQLQuery ISession.CreateSQLQuery(string queryString) - { - throw new NotImplementedException(); - } - - void ISession.Clear() - { - throw new NotImplementedException(); - } - - object ISession.Get(System.Type clazz, object id) - { - throw new NotImplementedException(); - } - - object ISession.Get(System.Type clazz, object id, LockMode lockMode) - { - throw new NotImplementedException(); - } - - object ISession.Get(string entityName, object id) - { - throw new NotImplementedException(); - } - - T ISession.Get<T>(object id) - { - throw new NotImplementedException(); - } - - T ISession.Get<T>(object id, LockMode lockMode) - { - throw new NotImplementedException(); - } - - string ISession.GetEntityName(object obj) - { - throw new NotImplementedException(); - } - - IFilter ISession.EnableFilter(string filterName) - { - throw new NotImplementedException(); - } - - IFilter ISession.GetEnabledFilter(string filterName) - { - throw new NotImplementedException(); - } - - void ISession.DisableFilter(string filterName) - { - throw new NotImplementedException(); - } - - IMultiQuery ISession.CreateMultiQuery() - { - throw new NotImplementedException(); - } - - ISession ISession.SetBatchSize(int batchSize) - { - throw new NotImplementedException(); - } - - NHibernate.Engine.ISessionImplementor ISession.GetSessionImplementation() - { - throw new NotImplementedException(); - } - - IMultiCriteria ISession.CreateMultiCriteria() - { - throw new NotImplementedException(); - } - - NHibernate.Stat.ISessionStatistics ISession.Statistics - { - get { throw new NotImplementedException(); } - } - - ISession ISession.GetSession(EntityMode entityMode) - { - throw new NotImplementedException(); - } - - void IDisposable.Dispose() - { - throw new NotImplementedException(); - } - - #endregion - - } - -} - Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-23 17:25:23 UTC (rev 4516) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-23 17:33:55 UTC (rev 4517) @@ -146,7 +146,6 @@ <Compile Include="Criteria\Lambda\CriteriaFixture.cs" /> <Compile Include="Criteria\Lambda\LambdaFixtureBase.cs" /> <Compile Include="Criteria\Lambda\Model.cs" /> - <Compile Include="Criteria\Lambda\SessionStub.cs" /> <Compile Include="Criteria\MaterialResource.cs" /> <Compile Include="Criteria\ProjectionsTest.cs" /> <Compile Include="Criteria\Reptile.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ric...@us...> - 2009-06-23 17:51:49
|
Revision: 4518 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4518&view=rev Author: RicBrown Date: 2009-06-23 17:51:48 +0000 (Tue, 23 Jun 2009) Log Message: ----------- Ported tests to check ICriteria comparison working OK. Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaAssertFixture.cs Added: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaAssertFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaAssertFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/CriteriaAssertFixture.cs 2009-06-23 17:51:48 UTC (rev 4518) @@ -0,0 +1,242 @@ + +using System; + +using NUnit.Framework; + +using NHibernate.Criterion; +using NHibernate.SqlCommand; + +namespace NHibernate.Test.Criteria.Lambda +{ + + [TestFixture] + public class CriteriaAssertFixture : LambdaFixtureBase + { + + private void AssertCriteriaAreNotEqual(ICriteria expected, ICriteria actual) + { + try + { + AssertCriteriaAreEqual(expected, actual); + } + catch + { + return; + } + Assert.Fail("No exception thrown"); + } + + private void AssertCriteriaAreNotEqual(DetachedCriteria expected, DetachedCriteria actual) + { + try + { + AssertCriteriaAreEqual(expected, actual); + } + catch + { + return; + } + Assert.Fail("No exception thrown"); + } + + [Test] + public void DifferentTypes() + { + DetachedCriteria expected = + DetachedCriteria.For<Person>(); + + DetachedCriteria actual = + DetachedCriteria.For<Child>(); + + AssertCriteriaAreNotEqual(expected, actual); + } + + [Test] + public void DifferentAliases() + { + DetachedCriteria expected = + DetachedCriteria.For<Person>("personAlias1"); + + DetachedCriteria actual = + DetachedCriteria.For<Person>("personAlias2"); + + AssertCriteriaAreNotEqual(expected, actual); + } + + [Test] + public void DifferentOperators() + { + DetachedCriteria expected = + DetachedCriteria.For<Person>() + .Add(Expression.Eq("Property", "Value")); + + DetachedCriteria actual = + DetachedCriteria.For<Person>() + .Add(Expression.Gt("Property", "Value")); + + AssertCriteriaAreNotEqual(expected, actual); + } + + [Test] + public void DifferentPaths() + { + DetachedCriteria expected = + DetachedCriteria.For<Person>() + .Add(Expression.Eq("a.b.Property1", "Value")); + + DetachedCriteria actual = + DetachedCriteria.For<Person>() + .Add(Expression.Eq("a.b.Property2", "Value")); + + AssertCriteriaAreNotEqual(expected, actual); + } + + [Test] + public void DifferentValues() + { + DetachedCriteria expected = + DetachedCriteria.For<Person>() + .Add(Expression.Eq("Property", "Value1")); + + DetachedCriteria actual = + DetachedCriteria.For<Person>() + .Add(Expression.Eq("Property", "Value2")); + + AssertCriteriaAreNotEqual(expected, actual); + } + + [Test] + public void DifferentNestedCriterion() + { + DetachedCriteria expected = + DetachedCriteria.For<Person>() + .Add(Expression.Not(Expression.Eq("Property", "Value"))); + + DetachedCriteria actual = + DetachedCriteria.For<Person>() + .Add(Expression.Not(Expression.Gt("Property", "Value"))); + + AssertCriteriaAreNotEqual(expected, actual); + } + + [Test] + public void DifferentOrder() + { + DetachedCriteria expected = + DetachedCriteria.For<Person>() + .AddOrder(Order.Asc("name")); + + DetachedCriteria actual = + DetachedCriteria.For<Person>() + .AddOrder(Order.Desc("name")); + + AssertCriteriaAreNotEqual(expected, actual); + } + + [Test] + public void DifferentSubCriteria() + { + DetachedCriteria expected = + DetachedCriteria.For<Person>() + .CreateCriteria("Child") + .Add(Expression.Eq("Name", "test")); + + DetachedCriteria actual = + DetachedCriteria.For<Person>() + .CreateCriteria("Child") + .Add(Expression.Gt("Name", "test")); + + AssertCriteriaAreNotEqual(expected, actual); + } + + [Test] + public void DifferentJoinType() + { + DetachedCriteria expected = + DetachedCriteria.For<Person>() + .CreateCriteria("Child", JoinType.InnerJoin); + + DetachedCriteria actual = + DetachedCriteria.For<Person>() + .CreateCriteria("Child", JoinType.LeftOuterJoin); + + AssertCriteriaAreNotEqual(expected, actual); + } + + [Test] + public void DifferentFetchMode() + { + DetachedCriteria expected = + DetachedCriteria.For<Person>() + .SetFetchMode("Father", FetchMode.Eager); + + DetachedCriteria actual = + DetachedCriteria.For<Person>() + .SetFetchMode("Father", FetchMode.Lazy); + + AssertCriteriaAreNotEqual(expected, actual); + } + + [Test] + public void DifferentLockMode() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .CreateAlias("Father", "fatherAlias") + .SetLockMode("fatherAlias", LockMode.Upgrade); + + ICriteria actual = + CreateTestCriteria(typeof(Person)) + .CreateAlias("Father", "fatherAlias") + .SetLockMode("fatherAlias", LockMode.Force); + + AssertCriteriaAreNotEqual(expected, actual); + } + + [Test] + public void DifferentProjections() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .SetProjection(Projections.Avg("Age")); + + ICriteria actual = + CreateTestCriteria(typeof(Person)) + .SetProjection(Projections.Max("Age")); + + AssertCriteriaAreNotEqual(expected, actual); + } + + [Test] + public void DifferentPropertyName() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .CreateAlias("Father", "fatherAlias") + .Add(Expression.GtProperty("Age1", "fatherAlias.Age")); + + ICriteria actual = + CreateTestCriteria(typeof(Person)) + .CreateAlias("Father", "fatherAlias") + .Add(Expression.GtProperty("Age2", "fatherAlias.Age")); + + AssertCriteriaAreNotEqual(expected, actual); + } + + [Test] + public void DifferentSubquery() + { + ICriteria expected = + CreateTestCriteria(typeof(Person)) + .Add(Subqueries.PropertyIn("Name", DetachedCriteria.For<Person>().Add(Expression.Eq("Name", "subquery test")))); + + ICriteria actual = + CreateTestCriteria(typeof(Person)) + .Add(Subqueries.PropertyIn("Name", DetachedCriteria.For<Person>().Add(Expression.Eq("Name", "subqueryx test")))); + + AssertCriteriaAreNotEqual(expected, actual); + } + + } + +} Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs 2009-06-23 17:33:55 UTC (rev 4517) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs 2009-06-23 17:51:48 UTC (rev 4518) @@ -10,5 +10,9 @@ public string Name { get; set; } } + public class Child + { + } + } Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-23 17:33:55 UTC (rev 4517) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-23 17:51:48 UTC (rev 4518) @@ -143,6 +143,7 @@ <Compile Include="Criteria\CriteriaQueryTest.cs" /> <Compile Include="Criteria\DetachedCriteriaSerializable.cs" /> <Compile Include="Criteria\Enrolment.cs" /> + <Compile Include="Criteria\Lambda\CriteriaAssertFixture.cs" /> <Compile Include="Criteria\Lambda\CriteriaFixture.cs" /> <Compile Include="Criteria\Lambda\LambdaFixtureBase.cs" /> <Compile Include="Criteria\Lambda\Model.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ric...@us...> - 2009-06-23 20:40:42
|
Revision: 4521 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4521&view=rev Author: RicBrown Date: 2009-06-23 20:40:40 +0000 (Tue, 23 Jun 2009) Log Message: ----------- Added integration test to check lambda expressions through to the DB and back. Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Mappings.hbm.xml Added: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs 2009-06-23 20:40:40 UTC (rev 4521) @@ -0,0 +1,71 @@ +using System; +using System.Collections; +using System.Collections.Generic; + +using NUnit.Framework; + +using NHibernate.Criterion; +using NHibernate.Transform; +using NHibernate.Type; +using NHibernate.Util; + +namespace NHibernate.Test.Criteria.Lambda +{ + + [TestFixture] + public class IntegrationFixture : TestCase + { + + protected override string MappingsAssembly { get { return "NHibernate.Test"; } } + + protected override IList Mappings + { + get + { + return new string[] + { + "Criteria.Lambda.Mappings.hbm.xml", + }; + } + } + + protected override void OnTearDown() + { + base.OnTearDown(); + + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.CreateQuery("delete from Person").ExecuteUpdate(); + s.CreateQuery("delete from Child").ExecuteUpdate(); + t.Commit(); + } + } + + [Test] + public void ICriteria_SimpleCriterion() + { + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Save(new Person() { Name = "test person 1" }); + s.Save(new Person() { Name = "test person 2" }); + s.Save(new Person() { Name = "test person 3" }); + + t.Commit(); + } + + using (ISession s = OpenSession()) + { + IList<Person> actual = + s.CreateCriteria(typeof(Person)) + .Add<Person>(p => p.Name == "test person 2") + .List<Person>(); + + Assert.That(actual.Count, Is.EqualTo(1)); + } + } + + } + +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Mappings.hbm.xml 2009-06-23 20:40:40 UTC (rev 4521) @@ -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.Criteria.Lambda"> + + <class name="Person"> + <id name="Id"> + <generator class="native"/> + </id> + <property name="Name" /> + </class> + + <class name="Child"> + <id name="Id"> + <generator class="native"/> + </id> + </class> + +</hibernate-mapping> Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs 2009-06-23 20:20:18 UTC (rev 4520) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs 2009-06-23 20:40:40 UTC (rev 4521) @@ -7,11 +7,13 @@ public class Person { - public string Name { get; set; } + public virtual int Id { get; set; } + public virtual string Name { get; set; } } public class Child { + public virtual int Id { get; set; } } } Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-23 20:20:18 UTC (rev 4520) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-23 20:40:40 UTC (rev 4521) @@ -145,6 +145,7 @@ <Compile Include="Criteria\Enrolment.cs" /> <Compile Include="Criteria\Lambda\CriteriaAssertFixture.cs" /> <Compile Include="Criteria\Lambda\CriteriaFixture.cs" /> + <Compile Include="Criteria\Lambda\IntegrationFixture.cs" /> <Compile Include="Criteria\Lambda\LambdaFixtureBase.cs" /> <Compile Include="Criteria\Lambda\Model.cs" /> <Compile Include="Criteria\MaterialResource.cs" /> @@ -1935,6 +1936,7 @@ <EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" /> <EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" /> <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> + <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> <EmbeddedResource Include="NHSpecificTest\NH1850\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1192\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <te...@us...> - 2009-07-01 20:36:09
|
Revision: 4559 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4559&view=rev Author: tehlike Date: 2009-07-01 20:36:07 +0000 (Wed, 01 Jul 2009) Log Message: ----------- Adding tests for NH-1849 Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/CustomDialect.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/Customer.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/Mappings.hbm.xml Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/CustomDialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/CustomDialect.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/CustomDialect.cs 2009-07-01 20:36:07 UTC (rev 4559) @@ -0,0 +1,13 @@ +using NHibernate.Dialect; +using NHibernate.Dialect.Function; + +namespace NHibernate.Test.NHSpecificTest.NH1849 +{ + public class CustomDialect : MsSql2005Dialect + { + public CustomDialect() + { + RegisterFunction("contains", new StandardSQLFunction("contains")); + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/Customer.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/Customer.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/Customer.cs 2009-07-01 20:36:07 UTC (rev 4559) @@ -0,0 +1,8 @@ +namespace NHibernate.Test.NHSpecificTest.NH1849 +{ + public class Customer + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/Fixture.cs 2009-07-01 20:36:07 UTC (rev 4559) @@ -0,0 +1,41 @@ +using NHibernate.Dialect; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1849 +{ + using Criterion; + + [TestFixture] + public class Fixture:BugTestCase + { + protected override bool AppliesTo(NHibernate.Dialect.Dialect dialect) + { + return dialect is MsSql2005Dialect; + } + + protected override void Configure(NHibernate.Cfg.Configuration configuration) + { + base.Configure(configuration); + + configuration.SetProperty("dialect", "NHibernate.Test.NHSpecificTest.NH1849.CustomDialect, NHibernate.Test"); + } + + /// <summary> + /// This test may throw an ado exception due to the absence of a full text index, + /// however the query should compile + /// </summary> + [Test,Ignore] + public void ExecutesCustomSqlFunctionContains() + { + sessions.Statistics.Clear(); + using (ISession session = this.OpenSession()) + { + session.CreateQuery("from Customer c where contains(c.Name, :smth)") + .SetString("smth","aaaa") + .List(); + + Assert.That(sessions.Statistics.QueryExecutionCount, Is.EqualTo(1)); + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/Mappings.hbm.xml 2009-07-01 20:36:07 UTC (rev 4559) @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1849" + default-lazy="false"> + + <class name="Customer"> + <id name="Id"> + <generator class="native"/> + </id> + <property name="Name"/> + </class> +</hibernate-mapping> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-01 20:17:23 UTC (rev 4558) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-01 20:36:07 UTC (rev 4559) @@ -526,6 +526,9 @@ <Compile Include="NHSpecificTest\NH1837\Customer.cs" /> <Compile Include="NHSpecificTest\NH1837\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1837\Order.cs" /> + <Compile Include="NHSpecificTest\NH1849\CustomDialect.cs" /> + <Compile Include="NHSpecificTest\NH1849\Customer.cs" /> + <Compile Include="NHSpecificTest\NH1849\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1850\Customer.cs" /> <Compile Include="NHSpecificTest\NH1850\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> @@ -1939,6 +1942,7 @@ <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1849\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1850\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1192\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1734\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-07-04 18:17:18
|
Revision: 4571 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4571&view=rev Author: fabiomaulo Date: 2009-07-04 18:17:15 +0000 (Sat, 04 Jul 2009) Log Message: ----------- Minor (reformatted) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/Customer.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Removed Paths: ------------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/CustomDialect.cs Deleted: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/CustomDialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/CustomDialect.cs 2009-07-04 15:45:57 UTC (rev 4570) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/CustomDialect.cs 2009-07-04 18:17:15 UTC (rev 4571) @@ -1,13 +0,0 @@ -using NHibernate.Dialect; -using NHibernate.Dialect.Function; - -namespace NHibernate.Test.NHSpecificTest.NH1849 -{ - public class CustomDialect : MsSql2005Dialect - { - public CustomDialect() - { - RegisterFunction("contains", new StandardSQLFunction("contains")); - } - } -} Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/Customer.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/Customer.cs 2009-07-04 15:45:57 UTC (rev 4570) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/Customer.cs 2009-07-04 18:17:15 UTC (rev 4571) @@ -1,8 +1,8 @@ namespace NHibernate.Test.NHSpecificTest.NH1849 { - public class Customer - { - public virtual int Id { get; set; } - public virtual string Name { get; set; } - } -} + public class Customer + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/Fixture.cs 2009-07-04 15:45:57 UTC (rev 4570) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1849/Fixture.cs 2009-07-04 18:17:15 UTC (rev 4571) @@ -1,41 +1,47 @@ +using NHibernate.Cfg; using NHibernate.Dialect; +using NHibernate.Dialect.Function; using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.NH1849 { - using Criterion; + public class CustomDialect : MsSql2005Dialect + { + public CustomDialect() + { + RegisterFunction("contains", new StandardSQLFunction("contains", NHibernateUtil.Boolean)); + } + } [TestFixture] - public class Fixture:BugTestCase - { - protected override bool AppliesTo(NHibernate.Dialect.Dialect dialect) - { - return dialect is MsSql2005Dialect; - } - - protected override void Configure(NHibernate.Cfg.Configuration configuration) - { - base.Configure(configuration); + public class Fixture : BugTestCase + { + protected override bool AppliesTo(Dialect.Dialect dialect) + { + return dialect is MsSql2005Dialect; + } - configuration.SetProperty("dialect", "NHibernate.Test.NHSpecificTest.NH1849.CustomDialect, NHibernate.Test"); - } + protected override void Configure(Configuration configuration) + { + base.Configure(configuration); - /// <summary> - /// This test may throw an ado exception due to the absence of a full text index, - /// however the query should compile - /// </summary> - [Test,Ignore] - public void ExecutesCustomSqlFunctionContains() - { - sessions.Statistics.Clear(); - using (ISession session = this.OpenSession()) + configuration.SetProperty("dialect", "NHibernate.Test.NHSpecificTest.NH1849.CustomDialect, NHibernate.Test"); + } + + /// <summary> + /// This test may throw an ado exception due to the absence of a full text index, + /// however the query should compile + /// </summary> + [Test, Ignore] + public void ExecutesCustomSqlFunctionContains() + { + sessions.Statistics.Clear(); + using (ISession session = OpenSession()) { - session.CreateQuery("from Customer c where contains(c.Name, :smth)") - .SetString("smth","aaaa") - .List(); + session.CreateQuery("from Customer c where contains(c.Name, :smth)").SetString("smth", "aaaa").List(); - Assert.That(sessions.Statistics.QueryExecutionCount, Is.EqualTo(1)); - } - } - } -} + Assert.That(sessions.Statistics.QueryExecutionCount, Is.EqualTo(1)); + } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-04 15:45:57 UTC (rev 4570) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-04 18:17:15 UTC (rev 4571) @@ -528,7 +528,6 @@ <Compile Include="NHSpecificTest\NH1837\Customer.cs" /> <Compile Include="NHSpecificTest\NH1837\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1837\Order.cs" /> - <Compile Include="NHSpecificTest\NH1849\CustomDialect.cs" /> <Compile Include="NHSpecificTest\NH1849\Customer.cs" /> <Compile Include="NHSpecificTest\NH1849\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1850\Customer.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-07-13 08:45:16
|
Revision: 4604 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4604&view=rev Author: ricbrown Date: 2009-07-13 08:45:12 +0000 (Mon, 13 Jul 2009) Log Message: ----------- Migrated ExpressionProcessor tests from lambda extensions. Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/ExpressionProcessorFixture.cs Added: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/ExpressionProcessorFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/ExpressionProcessorFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/ExpressionProcessorFixture.cs 2009-07-13 08:45:12 UTC (rev 4604) @@ -0,0 +1,104 @@ + +using System; +using System.Linq.Expressions; + +using NHibernate.Criterion; +using NHibernate.Impl; + +using NUnit.Framework; + +namespace NHibernate.Test.Criteria.Lambda +{ + + [TestFixture] + public class TestExpressionProcessor + { + + [Test] + public void TestFindMemberExpressionReference() + { + Expression<Func<Person, string>> e = (Person p) => p.Name; + string property = ExpressionProcessor.FindMemberExpression(e.Body); + Assert.AreEqual("Name", property); + } + + [Test] + public void TestFindMemberExpressionValue() + { + Expression<Func<Person, object>> e = (Person p) => p.Age; + string property = ExpressionProcessor.FindMemberExpression(e.Body); + Assert.AreEqual("Age", property); + } + + [Test] + public void TestEvaluatePropertyExpression() + { + string testName = "testName"; + ICriterion criterion = ExpressionProcessor.ProcessExpression<Person>(p => p.Name == testName); + SimpleExpression simpleExpression = (SimpleExpression)criterion; + Assert.AreEqual("testName", simpleExpression.Value); + } + + [Test] + public void TestEvaluateNullPropertyExpression() + { + Person person = new Person() { Name = null }; + ICriterion criterion = ExpressionProcessor.ProcessExpression<Person>(p => p.Name == person.Name); + SimpleExpression simpleExpression = (SimpleExpression)criterion; + Assert.AreEqual(null, simpleExpression.Value); + } + + [Test] + public void TestEvaluateStaticPropertyExpression() + { + Person.StaticName = "test name"; + ICriterion criterion = ExpressionProcessor.ProcessExpression<Person>(p => p.Name == Person.StaticName); + SimpleExpression simpleExpression = (SimpleExpression)criterion; + Assert.AreEqual("test name", simpleExpression.Value); + } + + [Test] + public void TestEvaluateEnumeration() + { + ICriterion before = Restrictions.Eq("Gender", PersonGender.Female); + ICriterion after = ExpressionProcessor.ProcessExpression<Person>(p => p.Gender == PersonGender.Female); + Assert.AreEqual(before.ToString(), after.ToString()); + } + + [Test] + public void TestEvaluateSubclass() + { + Person person = new CustomPerson(); + ICriterion before = Restrictions.Eq("Father", person); + ICriterion after = ExpressionProcessor.ProcessExpression<Person>(p => p.Father == person); + Assert.AreEqual(before.ToString(), after.ToString()); + } + + [Test] + public void TestEvaluateMemberExpression() + { + Person testPerson = new Person(); + testPerson.Name = "testName"; + ICriterion criterion = ExpressionProcessor.ProcessExpression<Person>(p => p.Name == testPerson.Name); + SimpleExpression simpleExpression = (SimpleExpression)criterion; + Assert.AreEqual("testName", simpleExpression.Value); + } + + [Test] + public void TestEvaluateBooleanMemberExpression() + { + { + ICriterion before = Restrictions.Eq("IsParent", true); + ICriterion after = ExpressionProcessor.ProcessExpression<Person>(p => p.IsParent); + Assert.AreEqual(before.ToString(), after.ToString()); + } + { + ICriterion before = Restrictions.Eq("IsParent", false); + ICriterion after = ExpressionProcessor.ProcessExpression<Person>(p => !p.IsParent); + Assert.AreEqual(before.ToString(), after.ToString()); + } + } + + } + +} Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs 2009-07-09 22:41:46 UTC (rev 4603) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/Model.cs 2009-07-13 08:45:12 UTC (rev 4604) @@ -5,18 +5,30 @@ namespace NHibernate.Test.Criteria.Lambda { + public enum PersonGender + { + Male = 1, + Female = 2, + } + public class Person { + public static string StaticName; + public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual int Age { get; set; } + public virtual PersonGender Gender { get; set; } public virtual int Height { get; set; } public virtual bool HasCar { get; set; } public virtual Person Father { get; set; } + public virtual bool IsParent { get; set; } public virtual IEnumerable<Child> Children { get; set; } } + public class CustomPerson : Person { } + public class Child { public virtual int Id { get; set; } Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-09 22:41:46 UTC (rev 4603) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-07-13 08:45:12 UTC (rev 4604) @@ -147,6 +147,7 @@ <Compile Include="Criteria\DetachedCriteriaSerializable.cs" /> <Compile Include="Criteria\Enrolment.cs" /> <Compile Include="Criteria\Lambda\CriteriaAssertFixture.cs" /> + <Compile Include="Criteria\Lambda\ExpressionProcessorFixture.cs" /> <Compile Include="Criteria\Lambda\QueryOverFixture.cs" /> <Compile Include="Criteria\Lambda\IntegrationFixture.cs" /> <Compile Include="Criteria\Lambda\LambdaFixtureBase.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <te...@us...> - 2009-09-21 02:05:16
|
Revision: 4720 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4720&view=rev Author: tehlike Date: 2009-09-21 02:04:47 +0000 (Mon, 21 Sep 2009) Log Message: ----------- Adding tests for NH-1963 Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1963/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1963/CacheableQueryOnByteArray.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1963/DomainClass.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1963/Mappings.hbm.xml Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1963/CacheableQueryOnByteArray.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1963/CacheableQueryOnByteArray.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1963/CacheableQueryOnByteArray.cs 2009-09-21 02:04:47 UTC (rev 4720) @@ -0,0 +1,96 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using NHibernate.Dialect; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1963 +{ + [TestFixture] + public class CacheableQueryOnByteArray : BugTestCase + { + protected override void OnSetUp() + { + base.OnSetUp(); + using (ISession session = this.OpenSession()) + { + DomainClass entity = new DomainClass(); + entity.Id = 1; + entity.ByteData = new byte[] {1, 2, 3}; + session.Save(entity); + session.Flush(); + } + } + + protected override void OnTearDown() + { + base.OnTearDown(); + using (ISession session = this.OpenSession()) + { + string hql = "from System.Object"; + session.Delete(hql); + session.Flush(); + } + } + + protected override bool AppliesTo(NHibernate.Dialect.Dialect dialect) + { + return dialect as MsSql2000Dialect != null; + } + + [Test,Ignore] + public void Should_be_able_to_do_cacheable_query_on_byte_array_field() + { + using (ISession session = this.OpenSession()) + { + var data = new byte[] { 1, 2, 3 }; + + var result = session.CreateQuery("from DomainClass d where d.ByteData = :data") + .SetParameter("data", data) + .SetCacheable(true) + .UniqueResult<DomainClass>(); + + Assert.IsNotNull(result); + } + + using (ISession session = this.OpenSession()) + { + var data = new byte[] { 1, 2, 3 }; + + var result = session.CreateQuery("from DomainClass d where d.ByteData = :data") + .SetParameter("data", data) + .SetCacheable(true) + .UniqueResult<DomainClass>(); + + Assert.IsNotNull(result); + } + } + + [Test] + public void Should_work_when_query_is_not_cachable() + { + using (ISession session = this.OpenSession()) + { + var data = new byte[] { 1, 2, 3 }; + + var result = session.CreateQuery("from DomainClass d where d.ByteData = :data") + .SetParameter("data", data) + .UniqueResult<DomainClass>(); + + Assert.IsNotNull(result); + } + + using (ISession session = this.OpenSession()) + { + var data = new byte[] { 1, 2, 3 }; + + var result = session.CreateQuery("from DomainClass d where d.ByteData = :data") + .SetParameter("data", data) + .UniqueResult<DomainClass>(); + + Assert.IsNotNull(result); + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1963/DomainClass.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1963/DomainClass.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1963/DomainClass.cs 2009-09-21 02:04:47 UTC (rev 4720) @@ -0,0 +1,22 @@ + + +namespace NHibernate.Test.NHSpecificTest.NH1963 +{ + public class DomainClass + { + private byte[] byteData; + private int id; + + public int Id + { + get { return id; } + set { id = value; } + } + + public byte[] ByteData + { + get { return byteData; } + set { byteData = value; } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1963/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1963/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1963/Mappings.hbm.xml 2009-09-21 02:04:47 UTC (rev 4720) @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1963" default-access="field.camelcase" + default-lazy="false"> + <class name="DomainClass"> + <id name="Id"> + <generator class="assigned" /> + </id> + <property name="ByteData"/> + </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-21 01:57:56 UTC (rev 4719) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-09-21 02:04:47 UTC (rev 4720) @@ -603,6 +603,8 @@ <Compile Include="NHSpecificTest\NH1938\Model.cs" /> <Compile Include="NHSpecificTest\NH1939\AuxType.cs" /> <Compile Include="NHSpecificTest\NH1939\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1963\CacheableQueryOnByteArray.cs" /> + <Compile Include="NHSpecificTest\NH1963\DomainClass.cs" /> <Compile Include="NHSpecificTest\NH1969\DummyEntity.cs" /> <Compile Include="NHSpecificTest\NH1969\EntityWithTypeProperty.cs" /> <Compile Include="NHSpecificTest\NH1969\Fixture.cs" /> @@ -2020,6 +2022,7 @@ <EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" /> <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1963\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1969\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1922\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\CriteriaQueryOnComponentCollection\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-10-18 20:37:58
|
Revision: 4790 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4790&view=rev Author: fabiomaulo Date: 2009-10-18 20:37:46 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Merge r4789 (subtask NH-1368) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Model.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsBag.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsList.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsSet.hbm.xml Removed Paths: ------------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Mappings.hbm.xml Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Fixture.cs 2009-10-18 20:30:38 UTC (rev 4789) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Fixture.cs 2009-10-18 20:37:46 UTC (rev 4790) @@ -1,10 +1,11 @@ +using System.Collections; using System.Collections.Generic; +using Iesi.Collections.Generic; using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.NH1356 { - [TestFixture] - public class Fixture : BugTestCase + public abstract class Fixture : BugTestCase { [Test] public void CanLoadWithGenericCompositeElement() @@ -13,9 +14,7 @@ { using (ITransaction tx = session.BeginTransaction()) { - Person person = new Person(); - person.Name = "Bob"; - person.Addresses = new List<Address>(); + var person = new Person {Name = "Bob", Addresses = NewCollection()}; person.Addresses.Add(new Address("123 Main St.", "Anytown", "LA", "12345")); person.Addresses.Add(new Address("456 Main St.", "Anytown", "LA", "12345")); @@ -25,7 +24,7 @@ } using (ISession session = OpenSession()) { - Person person = session.CreateQuery("from Person").UniqueResult<Person>(); + var person = session.CreateQuery("from Person").UniqueResult<Person>(); Assert.IsNotNull(person); Assert.IsNotNull(person.Addresses); @@ -40,5 +39,49 @@ } } } + + protected abstract ICollection<Address> NewCollection(); } + + [TestFixture] + public class FixtureWithList : Fixture + { + protected override IList Mappings + { + get { return new[] {"NHSpecificTest." + BugNumber + ".MappingsList.hbm.xml"}; } + } + + protected override ICollection<Address> NewCollection() + { + return new List<Address>(); + } + } + + [TestFixture] + public class FixtureWithBag : Fixture + { + protected override IList Mappings + { + get { return new[] {"NHSpecificTest." + BugNumber + ".MappingsBag.hbm.xml"}; } + } + + protected override ICollection<Address> NewCollection() + { + return new List<Address>(); + } + } + + [TestFixture] + public class FixtureWithSet : Fixture + { + protected override IList Mappings + { + get { return new[] {"NHSpecificTest." + BugNumber + ".MappingsSet.hbm.xml"}; } + } + + protected override ICollection<Address> NewCollection() + { + return new HashedSet<Address>(); + } + } } \ No newline at end of file Deleted: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Mappings.hbm.xml 2009-10-18 20:30:38 UTC (rev 4789) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Mappings.hbm.xml 2009-10-18 20:37:46 UTC (rev 4790) @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1356"> - <class name="Person" lazy="false"> - <id name="Id"> - <generator class="native" /> - </id> - <property name="Name" /> - - <list name="Addresses" table="Addresses" lazy="false"> - <key column="PersonId" /> - <index column="Position" /> - - <composite-element class="Address"> - <property name="Street" access="field.camelcase" /> - <property name="City" access="field.camelcase" /> - <property name="State" access="field.camelcase" /> - <property name="PostalCode" access="field.camelcase" /> - </composite-element> - </list> - </class> -</hibernate-mapping> Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsBag.hbm.xml (from rev 4789, branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsBag.hbm.xml) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsBag.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsBag.hbm.xml 2009-10-18 20:37:46 UTC (rev 4790) @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1356"> + <class name="Person" lazy="false"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="Name" /> + + <bag name="Addresses" table="Addresses" lazy="false" generic="true"> + <key column="PersonId" /> + + <composite-element class="Address"> + <property name="Street" access="field.camelcase" /> + <property name="City" access="field.camelcase" /> + <property name="State" access="field.camelcase" /> + <property name="PostalCode" access="field.camelcase" /> + </composite-element> + </bag> + </class> +</hibernate-mapping> Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsList.hbm.xml (from rev 4789, branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsList.hbm.xml) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsList.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsList.hbm.xml 2009-10-18 20:37:46 UTC (rev 4790) @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1356"> + <class name="Person" lazy="false"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="Name" /> + + <list name="Addresses" table="Addresses" lazy="false" generic="true"> + <key column="PersonId" /> + <index column="Position" /> + + <composite-element class="Address"> + <property name="Street" access="field.camelcase" /> + <property name="City" access="field.camelcase" /> + <property name="State" access="field.camelcase" /> + <property name="PostalCode" access="field.camelcase" /> + </composite-element> + </list> + </class> +</hibernate-mapping> Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsSet.hbm.xml (from rev 4789, branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsSet.hbm.xml) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsSet.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsSet.hbm.xml 2009-10-18 20:37:46 UTC (rev 4790) @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1356"> + <class name="Person" lazy="false"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="Name" /> + + <set name="Addresses" table="Addresses" lazy="false" generic="true"> + <key column="PersonId" /> + + <composite-element class="Address"> + <property name="Street" access="field.camelcase" /> + <property name="City" access="field.camelcase" /> + <property name="State" access="field.camelcase" /> + <property name="PostalCode" access="field.camelcase" /> + </composite-element> + </set> + </class> +</hibernate-mapping> Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Model.cs 2009-10-18 20:30:38 UTC (rev 4789) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Model.cs 2009-10-18 20:37:46 UTC (rev 4790) @@ -4,8 +4,7 @@ { public class Person { - private IList<Address> addressBag; - private IList<Address> addresses; + private ICollection<Address> addresses; private int id; private string name; @@ -21,17 +20,11 @@ set { name = value; } } - public IList<Address> Addresses + public ICollection<Address> Addresses { get { return addresses; } set { addresses = value; } } - - public IList<Address> AddressBag - { - get { return addressBag; } - set { addressBag = value; } - } } public struct Address Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-10-18 20:30:38 UTC (rev 4789) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-10-18 20:37:46 UTC (rev 4790) @@ -1985,9 +1985,6 @@ <EmbeddedResource Include="NHSpecificTest\NH693\SpaceTableName.hbm.xml" /> </ItemGroup> <ItemGroup> - <EmbeddedResource Include="NHSpecificTest\NH1356\Mappings.hbm.xml" /> - </ItemGroup> - <ItemGroup> <EmbeddedResource Include="NHSpecificTest\NH1362\Mappings.hbm.xml" /> </ItemGroup> <ItemGroup> @@ -2046,6 +2043,9 @@ <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1356\MappingsBag.hbm.xml" /> + <EmbeddedResource Include="NHSpecificTest\NH1356\MappingsList.hbm.xml" /> + <EmbeddedResource Include="NHSpecificTest\NH1356\MappingsSet.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1785\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1255\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1895\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2009-11-13 16:03:07
|
Revision: 4830 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4830&view=rev Author: steverstrong Date: 2009-11-13 16:02:56 +0000 (Fri, 13 Nov 2009) Log Message: ----------- Removed test that was causing compilation issues. To be investigated... Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/Linq/DynamicQueryTests.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/Linq/MethodCallTests.cs Modified: trunk/nhibernate/src/NHibernate.Test/Linq/DynamicQueryTests.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/DynamicQueryTests.cs 2009-11-13 15:44:38 UTC (rev 4829) +++ trunk/nhibernate/src/NHibernate.Test/Linq/DynamicQueryTests.cs 2009-11-13 16:02:56 UTC (rev 4830) @@ -1,6 +1,6 @@ using System; using System.Linq; -using System.Linq.Dynamic; +//using System.Linq.Dynamic; using NHibernate.Test.Linq.Entities; using NUnit.Framework; @@ -10,8 +10,10 @@ public class DynamicQueryTests : LinqTestCase { [Test] + [Ignore("TODO - works locally, but gives compile errors on teamcity")] public void CanQueryWithDynamicOrderBy() { + /* var query = from user in db.Users select user; @@ -27,6 +29,7 @@ Assert.IsTrue(previousDate <= user.RegisteredAt); previousDate = user.RegisteredAt; }); + */ } } } Added: trunk/nhibernate/src/NHibernate.Test/Linq/MethodCallTests.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/MethodCallTests.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Linq/MethodCallTests.cs 2009-11-13 16:02:56 UTC (rev 4830) @@ -0,0 +1,32 @@ +using System.Linq; +using NUnit.Framework; + +namespace NHibernate.Test.Linq +{ + [TestFixture] + [Ignore] + public class MethodCallTests : LinqTestCase + { + [Test] + public void CanExecuteAny() + { + bool result = db.Users.Any(); + Assert.IsTrue(result); + } + + [Test] + public void CanExecuteAnyWithArguments() + { + bool result = db.Users.Any(u => u.Name == "user-does-not-exist"); + Assert.IsFalse(result); + } + + [Test] + public void CanExecuteCountWithOrderByArguments() + { + var query = db.Users.OrderBy(u => u.Name); + int count = query.Count(); + Assert.AreEqual(3, count); + } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-11-13 15:44:38 UTC (rev 4829) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-11-13 16:02:56 UTC (rev 4830) @@ -407,6 +407,7 @@ <Compile Include="Linq\FunctionTests.cs" /> <Compile Include="Linq\LinqQuerySamples.cs" /> <Compile Include="Linq\LinqTestCase.cs" /> + <Compile Include="Linq\MethodCallTests.cs" /> <Compile Include="Linq\MiscellaneousTextFixture.cs" /> <Compile Include="Linq\ObjectDumper.cs" /> <Compile Include="Linq\ParameterisedQueries.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2009-11-25 21:46:15
|
Revision: 4859 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4859&view=rev Author: steverstrong Date: 2009-11-25 21:46:06 +0000 (Wed, 25 Nov 2009) Log Message: ----------- More Linq test cases added Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Northwind.cs trunk/nhibernate/src/NHibernate.Test/Linq/LinqTestCase.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Patient.cs trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/Patient.hbm.xml trunk/nhibernate/src/NHibernate.Test/Linq/OrderByTests.cs trunk/nhibernate/src/NHibernate.Test/Linq/PagingTests.cs trunk/nhibernate/src/NHibernate.Test/Linq/PatientTests.cs Modified: trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Northwind.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Northwind.cs 2009-11-25 20:16:50 UTC (rev 4858) +++ trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Northwind.cs 2009-11-25 21:46:06 UTC (rev 4859) @@ -1,4 +1,6 @@ -using System.Linq; +using System; +using System.Collections.Generic; +using System.Linq; using NHibernate.Linq; namespace NHibernate.Test.Linq.Entities @@ -61,5 +63,25 @@ { get { return _session.Query<User>(); } } + + public IQueryable<PatientRecord> PatientRecords + { + get { return _session.Query<PatientRecord>(); } + } + + public IQueryable<State> States + { + get { return _session.Query<State>(); } + } + + public IQueryable<Patient> Patients + { + get { return _session.Query<Patient>(); } + } + + public IQueryable<Physician> Physicians + { + get { return _session.Query<Physician>(); } + } } } \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Patient.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Patient.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Linq/Entities/Patient.cs 2009-11-25 21:46:06 UTC (rev 4859) @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; + +namespace NHibernate.Test.Linq.Entities +{ + public class Patient + { + private IList<PatientRecord> patientRecords; + private bool active; + private Physician physician; + + protected Patient() { } + public Patient(IEnumerable<PatientRecord> patientRecords, bool active, Physician physician) + { + this.active = active; + this.physician = physician; + this.patientRecords = new List<PatientRecord>(patientRecords); + foreach (var record in this.patientRecords) + { + record.Patient = this; + } + } + + public virtual long Id { get; set; } + + public virtual bool Active + { + get { return active; } + set { active = value; } + } + + public virtual IList<PatientRecord> PatientRecords + { + get { return patientRecords; } + set { patientRecords = value; } + } + + public virtual Physician Physician + { + get { return physician; } + set { physician = value; } + } + } + + public class Physician + { + public virtual long Id { get; set; } + public virtual string Name { get; set; } + } + + public class PatientRecord + { + public virtual long Id { get; set; } + public virtual PatientName Name { get; set; } + public virtual DateTime BirthDate { get; set; } + public virtual Gender Gender { get; set; } + public virtual PatientAddress Address { get; set; } + public virtual Patient Patient { get; set; } + } + + public enum Gender + { + Unknown, + Male, + Female + } + + public class PatientName + { + public virtual string FirstName { get; set; } + public virtual string LastName { get; set; } + } + + public class PatientAddress + { + public virtual string AddressLine1 { get; set; } + public virtual string AddressLine2 { get; set; } + public virtual string City { get; set; } + public virtual State State { get; set; } + public virtual string ZipCode { get; set; } + } + public class State + { + public virtual long Id { get; set; } + public virtual string Abbreviation { get; set; } + public virtual string FullName { get; set; } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/Linq/LinqTestCase.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/LinqTestCase.cs 2009-11-25 20:16:50 UTC (rev 4858) +++ trunk/nhibernate/src/NHibernate.Test/Linq/LinqTestCase.cs 2009-11-25 21:46:06 UTC (rev 4859) @@ -49,7 +49,8 @@ "Linq.Mappings.Role.hbm.xml", "Linq.Mappings.User.hbm.xml", "Linq.Mappings.TimeSheet.hbm.xml", - "Linq.Mappings.Animal.hbm.xml" + "Linq.Mappings.Animal.hbm.xml", + "Linq.Mappings.Patient.hbm.xml" }; } @@ -69,7 +70,7 @@ using (ITransaction tx = session.BeginTransaction()) { CreateMiscTestData(session); - + CreatePatientData(session); tx.Commit(); } } @@ -220,6 +221,93 @@ session.Save(animal); } + private void CreatePatientData(ISession session) + { + State newYork = new State + { + Abbreviation = "NY", + FullName = "New York" + }; + State florida = new State + { + Abbreviation = "FL", + FullName = "Florida" + }; + + Physician drDobbs = new Physician + { + Name = "Dr Dobbs" + }; + Physician drWatson = new Physician + { + Name = "Dr Watson" + }; + + PatientRecord bobBarkerRecord = new PatientRecord + { + Name = new PatientName + { + FirstName = "Bob", + LastName = "Barker" + }, + Address = new PatientAddress + { + AddressLine1 = "123 Main St", + City = "New York", + State = newYork, + ZipCode = "10001" + }, + BirthDate = new DateTime(1930, 1, 1), + Gender = Gender.Male + }; + + PatientRecord johnDoeRecord1 = new PatientRecord + { + Name = new PatientName + { + FirstName = "John", + LastName = "Doe" + }, + Address = new PatientAddress + { + AddressLine1 = "123 Main St", + City = "Tampa", + State = florida, + ZipCode = "33602" + }, + BirthDate = new DateTime(1969, 1, 1), + Gender = Gender.Male + }; + + PatientRecord johnDoeRecord2 = new PatientRecord + { + Name = new PatientName + { + FirstName = "John", + LastName = "Doe" + }, + Address = new PatientAddress + { + AddressLine1 = "123 Main St", + AddressLine2 = "Apt 2", + City = "Tampa", + State = florida, + ZipCode = "33602" + }, + BirthDate = new DateTime(1969, 1, 1) + }; + + Patient bobBarker = new Patient(new[] { bobBarkerRecord }, false, drDobbs); + Patient johnDoe = new Patient(new[] { johnDoeRecord1, johnDoeRecord2 }, true, drWatson); + + session.Save(newYork); + session.Save(florida); + session.Save(drDobbs); + session.Save(drWatson); + session.Save(bobBarker); + session.Save(johnDoe); + } + private void CreateNorthwindData(IStatelessSession session) { var shippers = new List<Shipper>(); Added: trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/Patient.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/Patient.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Linq/Mappings/Patient.hbm.xml 2009-11-25 21:46:06 UTC (rev 4859) @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NHibernate.Test.Linq.Entities" assembly="NHibernate.Test"> + <class name="Patient" table="Patients"> + <id name="Id" column="PatientId" type="Int64"> + <generator class="native" /> + </id> + <property type="System.Boolean" not-null="true" name="Active" column="[Active]" /> + <many-to-one name="Physician" cascade="none" column="PhysicianId" not-null="true" class="Physician" /> + <bag name="PatientRecords" inverse="true" lazy="true" cascade="all"> + <key column="PatientId" /> + <one-to-many class="PatientRecord" /> + </bag> + </class> + + <class name="Physician" table="Physicians"> + <id name="Id" column="PhysicianId" type="Int64"> + <generator class="native" /> + </id> + <property type="System.String" not-null="true" name="Name" column="[Name]" /> + </class> + + <class name="PatientRecord" table="PatientRecords"> + <id name="Id" column="PatientRecordId" type="System.Int64"> + <generator class="native" /> + </id> + <property type="NHibernate.Test.Linq.Entities.Gender, NHibernate.Test" not-null="true" name="Gender" column="[Gender]" /> + <property type="System.DateTime" not-null="true" name="BirthDate" column="[BirthDate]" /> + + <component name="Name" class="PatientName"> + <property type="System.String" not-null="true" name="FirstName" column="[FirstName]" /> + <property type="System.String" not-null="true" name="LastName" column="[LastName]" /> + </component> + + <component name="Address" class="PatientAddress"> + + <property type="System.String" name="AddressLine1" column="[AddressLine1]" /> + + <property type="System.String" name="AddressLine2" column="[AddressLine2]" /> + + <property type="System.String" name="City" column="[City]" /> + + <many-to-one name="State" cascade="none" column="StateId" class="State" /> + + <property type="System.String" name="ZipCode" column="[ZipCode]" /> + + </component> + + + <many-to-one name="Patient" cascade="none" column="PatientId" not-null="true" class="Patient" /> + </class> + + <class name="State" table="States"> + <id name="Id" column="StateId" type="System.Int64"> + <generator class="native" /> + </id> + <property type="System.String" not-null="true" name="Abbreviation" column="[Abbreviation]" /> + <property type="System.String" not-null="true" name="FullName" column="[FullName]" /> + </class> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/Linq/OrderByTests.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/OrderByTests.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Linq/OrderByTests.cs 2009-11-25 21:46:06 UTC (rev 4859) @@ -0,0 +1,119 @@ +using System.Linq; +using NUnit.Framework; + +namespace NHibernate.Test.Linq +{ + [TestFixture] + public class OrderByTests : LinqTestCase + { + [Test] + public void AscendingOrderByClause() + { + var query = from c in db.Customers + orderby c.CustomerId + select c.CustomerId; + + var ids = query.ToList(); + + if (ids.Count > 1) + { + Assert.Greater(ids[1], ids[0]); + } + } + + [Test] + public void DescendingOrderByClause() + { + var query = from c in db.Customers + orderby c.CustomerId descending + select c.CustomerId; + + var ids = query.ToList(); + + if (ids.Count > 1) + { + Assert.Greater(ids[0], ids[1]); + } + } + + [Test] + [Ignore("NHibernate does not currently support subqueries in select clause (no way to specify a projection from a detached criteria).")] + public void AggregateAscendingOrderByClause() + { + var query = from c in db.Customers + orderby c.Orders.Count + select c; + + var customers = query.ToList(); + + if (customers.Count > 1) + { + Assert.Less(customers[0].Orders.Count, customers[1].Orders.Count); + } + } + + [Test] + [Ignore("NHibernate does not currently support subqueries in select clause (no way to specify a projection from a detached criteria).")] + public void AggregateDescendingOrderByClause() + { + var query = from c in db.Customers + orderby c.Orders.Count descending + select c; + + var customers = query.ToList(); + + if (customers.Count > 1) + { + Assert.Greater(customers[0].Orders.Count, customers[1].Orders.Count); + } + } + + [Test] + public void ComplexAscendingOrderByClause() + { + var query = from c in db.Customers + where c.Address.Country == "Belgium" + orderby c.Address.Country, c.Address.City + select c.Address.City; + + var ids = query.ToList(); + + if (ids.Count > 1) + { + Assert.Greater(ids[1], ids[0]); + } + } + + [Test] + public void ComplexDescendingOrderByClause() + { + var query = from c in db.Customers + where c.Address.Country == "Belgium" + orderby c.Address.Country descending, c.Address.City descending + select c.Address.City; + + var ids = query.ToList(); + + if (ids.Count > 1) + { + Assert.Greater(ids[0], ids[1]); + } + } + + [Test] + public void ComplexAscendingDescendingOrderByClause() + { + var query = from c in db.Customers + where c.Address.Country == "Belgium" + orderby c.Address.Country ascending, c.Address.City descending + select c.Address.City; + + var ids = query.ToList(); + + if (ids.Count > 1) + { + Assert.Greater(ids[0], ids[1]); + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Linq/PagingTests.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/PagingTests.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Linq/PagingTests.cs 2009-11-25 21:46:06 UTC (rev 4859) @@ -0,0 +1,63 @@ +using System.Linq; +using NUnit.Framework; + +namespace NHibernate.Test.Linq +{ + [TestFixture] + public class PagingTests : LinqTestCase + { + [Test] + public void Customers1to5() + { + var q = (from c in db.Customers select c.CustomerId).Take(5); + var query = q.ToList(); + + Assert.AreEqual(5, query.Count); + } + + [Test] + public void Customers11to20() + { + var query = (from c in db.Customers + orderby c.CustomerId + select c.CustomerId).Skip(10).Take(10).ToList(); + Assert.AreEqual(query[0], "BSBEV"); + Assert.AreEqual(10, query.Count); + } + + [Test] + [Ignore("NHibernate does not currently support subqueries in from clause")] + public void CustomersChainedTake() + { + var q = (from c in db.Customers + orderby c.CustomerId + select c.CustomerId).Take(5).Take(6); + + var query = q.ToList(); + + Assert.AreEqual(5, query.Count); + Assert.AreEqual("ALFKI", query[0]); + Assert.AreEqual("BLAUS", query[4]); + } + + [Test] + [Ignore("NHibernate does not currently support subqueries in from clause")] + public void CustomersChainedSkip() + { + var q = (from c in db.Customers select c.CustomerId).Skip(10).Skip(5); + var query = q.ToList(); + Assert.AreEqual(query[0], "CONSH"); + Assert.AreEqual(76, query.Count); + } + + + + [Test] + [Ignore("NHibernate does not currently support subqueries in from clause")] + public void CountAfterTakeShouldReportTheCorrectNumber() + { + var users = db.Customers.Skip(3).Take(10); + Assert.AreEqual(10, users.Count()); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Linq/PatientTests.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/PatientTests.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Linq/PatientTests.cs 2009-11-25 21:46:06 UTC (rev 4859) @@ -0,0 +1,84 @@ +using System.Linq; +using NHibernate.Test.Linq.Entities; +using NUnit.Framework; + +namespace NHibernate.Test.Linq +{ + [TestFixture] + public class PatientTests : LinqTestCase + { + [Test] + public void CanQueryOnPropertyOfComponent() + { + var query = (from pr in db.PatientRecords + where pr.Name.LastName == "Doe" + select pr).ToList(); + + Assert.AreEqual(2, query.Count); + } + + [Test] + public void CanQueryOnManyToOneOfComponent() + { + var florida = db.States.FirstOrDefault(x => x.Abbreviation == "FL"); + + var query = (from pr in db.PatientRecords + where pr.Address.State == florida + select pr).ToList(); + + Assert.AreEqual(2, query.Count); + } + + [Test] + public void CanQueryOnPropertyOfManyToOneOfComponent() + { + var query = (from pr in db.PatientRecords + where pr.Address.State.Abbreviation == "FL" + select pr).ToList(); + + Assert.AreEqual(2, query.Count); + } + + [Test] + public void CanQueryOnPropertyOfOneToMany() + { + var query = (from p in db.Patients + where p.PatientRecords.Any(x => x.Gender == Gender.Unknown) + select p).ToList(); + + Assert.AreEqual(1, query.Count); + } + + [Test] + public void CanQueryOnPropertyOfManyToOne() + { + var query = (from pr in db.PatientRecords + where pr.Patient.Active == true + select pr).ToList(); + + Assert.AreEqual(2, query.Count); + } + + [Test] + public void CanQueryOnManyToOneOfManyToOne() + { + var drWatson = db.Physicians.FirstOrDefault(x => x.Name == "Dr Watson"); + + var query = (from pr in db.PatientRecords + where pr.Patient.Physician == drWatson + select pr).ToList(); + + Assert.AreEqual(2, query.Count); + } + + [Test] + public void CanQueryOnPropertyOfManyToOneOfManyToOne() + { + var query = (from pr in db.PatientRecords + where pr.Patient.Physician.Name == "Dr Watson" + select pr).ToList(); + + Assert.AreEqual(2, query.Count); + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-11-25 20:16:50 UTC (rev 4858) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-11-25 21:46:06 UTC (rev 4859) @@ -394,6 +394,7 @@ <Compile Include="Linq\Entities\Northwind.cs" /> <Compile Include="Linq\Entities\Order.cs" /> <Compile Include="Linq\Entities\OrderLine.cs" /> + <Compile Include="Linq\Entities\Patient.cs" /> <Compile Include="Linq\Entities\Product.cs" /> <Compile Include="Linq\Entities\ProductCategory.cs" /> <Compile Include="Linq\Entities\Region.cs" /> @@ -412,7 +413,10 @@ <Compile Include="Linq\MethodCallTests.cs" /> <Compile Include="Linq\MiscellaneousTextFixture.cs" /> <Compile Include="Linq\ObjectDumper.cs" /> + <Compile Include="Linq\OrderByTests.cs" /> + <Compile Include="Linq\PagingTests.cs" /> <Compile Include="Linq\ParameterisedQueries.cs" /> + <Compile Include="Linq\PatientTests.cs" /> <Compile Include="Linq\ReadonlyTestCase.cs" /> <Compile Include="MappingTest\NonReflectiveBinderFixture.cs" /> <Compile Include="MappingTest\Wicked.cs" /> @@ -2081,6 +2085,7 @@ <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="Linq\Mappings\Patient.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2011\Mappings.hbm.xml" /> <EmbeddedResource Include="Linq\Mappings\Animal.hbm.xml" /> <EmbeddedResource Include="Linq\Mappings\AnotherEntity.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2010-03-03 17:29:17
|
Revision: 4952 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4952&view=rev Author: ayenderahien Date: 2010-03-03 17:29:11 +0000 (Wed, 03 Mar 2010) Log Message: ----------- Adding passing test Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/App.config trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs Modified: trunk/nhibernate/src/NHibernate.Test/App.config =================================================================== --- trunk/nhibernate/src/NHibernate.Test/App.config 2010-03-03 15:54:34 UTC (rev 4951) +++ trunk/nhibernate/src/NHibernate.Test/App.config 2010-03-03 17:29:11 UTC (rev 4952) @@ -62,7 +62,7 @@ <!-- This is the System.Data.dll provider for MSSQL Server --> <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property> <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property> - <property name="connection.connection_string">Server=localhost;initial catalog=nhibernate;Integrated Security=SSPI</property> + <property name="connection.connection_string">Server=localhost\sqlexpress;initial catalog=nhibernate;Integrated Security=SSPI</property> <property name="show_sql">false</property> <property name="use_outer_join">true</property> Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs 2010-03-03 15:54:34 UTC (rev 4951) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Fixture.cs 2010-03-03 17:29:11 UTC (rev 4952) @@ -31,5 +31,31 @@ .List(); } } + + [Test] + public void QueryPropertyInBothFilterAndQueryUsingWith() + { + using (ISession s = OpenSession()) + { + s.EnableFilter("validity") + .SetParameter("date", DateTime.Now); + + s.CreateQuery(@" + select + inv.ID + from + Invoice inv + join inv.Category cat with cat.ValidUntil > :now + left join cat.ParentCategory parentCat with parentCat.ID != :myInt + where + inv.ID = :invId + and inv.Issued < :now + ") + .SetDateTime("now", DateTime.Now) + .SetInt32("invId", -999) + .SetInt32("myInt", -888) + .List(); + } + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs 2010-03-03 15:54:34 UTC (rev 4951) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1908/Model.cs 2010-03-03 17:29:11 UTC (rev 4952) @@ -15,4 +15,4 @@ public virtual DateTime Issued { get; set; } public virtual Category Category { get; set; } } -} \ No newline at end of file +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-06-18 04:33:12
|
Revision: 4986 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4986&view=rev Author: fabiomaulo Date: 2010-06-18 04:33:05 +0000 (Fri, 18 Jun 2010) Log Message: ----------- Refactoring of Linq readonly tests (overboost) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/App.config trunk/nhibernate/src/NHibernate.Test/Linq/LinqTestCase.cs trunk/nhibernate/src/NHibernate.Test/Linq/ParameterisedQueries.cs trunk/nhibernate/src/NHibernate.Test/Linq/ProjectionsTests.cs trunk/nhibernate/src/NHibernate.Test/Linq/ReadonlyTestCase.cs trunk/nhibernate/src/NHibernate.Test/Linq/SelectionTests.cs trunk/nhibernate/src/NHibernate.Test/Linq/WhereTests.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.build trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/DbScripts/ trunk/nhibernate/src/NHibernate.Test/DbScripts/MsSql2008DialectLinqReadonlyCreateScript.sql trunk/nhibernate/src/NHibernate.Test/DbScripts/MsSql2008DialectLinqReadonlyDropScript.sql trunk/nhibernate/src/NHibernate.Test/Linq/LinqReadonlyTestsContext.cs trunk/nhibernate/src/NHibernate.Test/Linq/NorthwindDbCreator.cs Modified: trunk/nhibernate/src/NHibernate.Test/App.config =================================================================== --- trunk/nhibernate/src/NHibernate.Test/App.config 2010-05-29 19:25:32 UTC (rev 4985) +++ trunk/nhibernate/src/NHibernate.Test/App.config 2010-06-18 04:33:05 UTC (rev 4986) @@ -61,7 +61,7 @@ <!-- This is the System.Data.dll provider for MSSQL Server --> <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property> - <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property> + <property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property> <property name="connection.connection_string">Server=localhost\sqlexpress;initial catalog=nhibernate;Integrated Security=SSPI</property> <property name="show_sql">false</property> Added: trunk/nhibernate/src/NHibernate.Test/DbScripts/MsSql2008DialectLinqReadonlyCreateScript.sql =================================================================== (Binary files differ) Property changes on: trunk/nhibernate/src/NHibernate.Test/DbScripts/MsSql2008DialectLinqReadonlyCreateScript.sql ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/nhibernate/src/NHibernate.Test/DbScripts/MsSql2008DialectLinqReadonlyDropScript.sql =================================================================== (Binary files differ) Property changes on: trunk/nhibernate/src/NHibernate.Test/DbScripts/MsSql2008DialectLinqReadonlyDropScript.sql ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/nhibernate/src/NHibernate.Test/Linq/LinqReadonlyTestsContext.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/LinqReadonlyTestsContext.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Linq/LinqReadonlyTestsContext.cs 2010-06-18 04:33:05 UTC (rev 4986) @@ -0,0 +1,139 @@ +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.IO; +using System.Linq; +using System.Reflection; +using NHibernate.Cfg; +using NHibernate.Connection; +using NHibernate.Tool.hbm2ddl; +using NUnit.Framework; + +namespace NHibernate.Test.Linq +{ + [SetUpFixture] + public class LinqReadonlyTestsContext + { + private IEnumerable<string> Mappings + { + get + { + return new[] + { + "Linq.Mappings.Customer.hbm.xml", + "Linq.Mappings.Employee.hbm.xml", + "Linq.Mappings.Order.hbm.xml", + "Linq.Mappings.OrderLine.hbm.xml", + "Linq.Mappings.Product.hbm.xml", + "Linq.Mappings.ProductCategory.hbm.xml", + "Linq.Mappings.Region.hbm.xml", + "Linq.Mappings.Shipper.hbm.xml", + "Linq.Mappings.Supplier.hbm.xml", + "Linq.Mappings.Territory.hbm.xml", + "Linq.Mappings.AnotherEntity.hbm.xml", + "Linq.Mappings.Role.hbm.xml", + "Linq.Mappings.User.hbm.xml", + "Linq.Mappings.TimeSheet.hbm.xml", + "Linq.Mappings.Animal.hbm.xml", + "Linq.Mappings.Patient.hbm.xml" + }; + } + } + + [SetUp] + public void CreateNorthwindDb() + { + Configuration configuration = Configure(); + string scripFileName = GetScripFileName(configuration, "LinqReadonlyCreateScript"); + if (File.Exists(scripFileName)) + { + ExecuteScriptFile(configuration, scripFileName); + } + else + { + // may crash with NUnit2.5+ test runner + new SchemaExport(configuration).Create(false, true); + ISessionFactory sessionFactory = configuration.BuildSessionFactory(); + CreateTestData(sessionFactory); + } + } + + private void ExecuteScriptFile(Configuration configuration, string scripFileName) + { + var file = new FileInfo(scripFileName); + string script = file.OpenText().ReadToEnd().Replace("GO", ""); + var connectionProvider = ConnectionProviderFactory.NewConnectionProvider(configuration.Properties); + using (var conn = connectionProvider.GetConnection()) + { + if (conn.State == ConnectionState.Closed) + { + conn.Open(); + } + using (var command = conn.CreateCommand()) + { + command.CommandText = script; + command.ExecuteNonQuery(); + } + } + } + + [TearDown] + public void DestroyNorthwindDb() + { + Configuration configuration = Configure(); + string scripFileName = GetScripFileName(configuration, "LinqReadonlyDropScript"); + if (File.Exists(scripFileName)) + { + ExecuteScriptFile(configuration, scripFileName); + } + else + { + new SchemaExport(configuration).Drop(false, true); + } + } + + private string GetScripFileName(Configuration configuration,string postFix) + { + var dialect = Dialect.Dialect.GetDialect(configuration.Properties); + return Path.Combine("DbScripts", dialect.GetType().Name + postFix + ".sql"); + } + + private Configuration Configure() + { + var configuration = new Configuration(); + if (TestConfigurationHelper.hibernateConfigFile != null) + configuration.Configure(TestConfigurationHelper.hibernateConfigFile); + + configuration.SetProperty(Environment.ConnectionProvider, typeof (DriverConnectionProvider).AssemblyQualifiedName); + + string assemblyName = "NHibernate.Test"; + Assembly assembly = Assembly.Load(assemblyName); + + foreach (string file in Mappings.Select(mf => assemblyName + "." + mf)) + { + configuration.AddResource(file, assembly); + } + + return configuration; + } + + private void CreateTestData(ISessionFactory sessionFactory) + { + using (IStatelessSession session = sessionFactory.OpenStatelessSession()) + using (ITransaction tx = session.BeginTransaction()) + { + NorthwindDbCreator.CreateNorthwindData(session); + + tx.Commit(); + } + + using (ISession session = sessionFactory.OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + NorthwindDbCreator.CreateMiscTestData(session); + NorthwindDbCreator.CreatePatientData(session); + tx.Commit(); + } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/Linq/LinqTestCase.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/LinqTestCase.cs 2010-05-29 19:25:32 UTC (rev 4985) +++ trunk/nhibernate/src/NHibernate.Test/Linq/LinqTestCase.cs 2010-06-18 04:33:05 UTC (rev 4986) @@ -1,3572 +1,73 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq; using NHibernate.Test.Linq.Entities; using NUnit.Framework; namespace NHibernate.Test.Linq { - public class LinqTestCase : ReadonlyTestCase - { - private Northwind _northwind; - private ISession _session; + public class LinqTestCase : ReadonlyTestCase + { + private Northwind _northwind; + private ISession _session; - protected override bool PerformDbDataSetup - { - get { return true; } - } + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } - protected override bool PerformDbDataTeardown - { - get { return true; } - } + protected override IList Mappings + { + get + { + return new[] + { + "Linq.Mappings.Customer.hbm.xml", + "Linq.Mappings.Employee.hbm.xml", + "Linq.Mappings.Order.hbm.xml", + "Linq.Mappings.OrderLine.hbm.xml", + "Linq.Mappings.Product.hbm.xml", + "Linq.Mappings.ProductCategory.hbm.xml", + "Linq.Mappings.Region.hbm.xml", + "Linq.Mappings.Shipper.hbm.xml", + "Linq.Mappings.Supplier.hbm.xml", + "Linq.Mappings.Territory.hbm.xml", + "Linq.Mappings.AnotherEntity.hbm.xml", + "Linq.Mappings.Role.hbm.xml", + "Linq.Mappings.User.hbm.xml", + "Linq.Mappings.TimeSheet.hbm.xml", + "Linq.Mappings.Animal.hbm.xml", + "Linq.Mappings.Patient.hbm.xml" + }; + } + } - protected override string MappingsAssembly - { - get { return "NHibernate.Test"; } - } + protected Northwind db + { + get { return _northwind; } + } - protected override IList Mappings - { - get - { - return new[] - { - "Linq.Mappings.Customer.hbm.xml", - "Linq.Mappings.Employee.hbm.xml", - "Linq.Mappings.Order.hbm.xml", - "Linq.Mappings.OrderLine.hbm.xml", - "Linq.Mappings.Product.hbm.xml", - "Linq.Mappings.ProductCategory.hbm.xml", - "Linq.Mappings.Region.hbm.xml", - "Linq.Mappings.Shipper.hbm.xml", - "Linq.Mappings.Supplier.hbm.xml", - "Linq.Mappings.Territory.hbm.xml", - "Linq.Mappings.AnotherEntity.hbm.xml", - "Linq.Mappings.Role.hbm.xml", - "Linq.Mappings.User.hbm.xml", - "Linq.Mappings.TimeSheet.hbm.xml", - "Linq.Mappings.Animal.hbm.xml", - "Linq.Mappings.Patient.hbm.xml" + protected ISession session + { + get { return _session; } + } - }; - } - } + protected override void OnSetUp() + { + base.OnSetUp(); - private void CreateTestData() - { - using (IStatelessSession session = _sessions.OpenStatelessSession()) - using (ITransaction tx = session.BeginTransaction()) - { - CreateNorthwindData(session); + _session = OpenSession(); + _northwind = new Northwind(_session); + } - tx.Commit(); - } - - using (ISession session = _sessions.OpenSession()) - using (ITransaction tx = session.BeginTransaction()) - { - CreateMiscTestData(session); - CreatePatientData(session); - tx.Commit(); - } - } - - private void CreateMiscTestData(ISession session) - { - var roles = new[] - { - new Role() - { - Name = "Admin", - IsActive = true, - Entity = new AnotherEntity() - { - Output = "this is output..." - } - }, - new Role() - { - Name = "User", - IsActive = false - } - }; - - var users = new[] - { - new User("ayende", DateTime.Today) - { - Role = roles[0], - InvalidLoginAttempts = 4, - Enum1 = EnumStoredAsString.Medium, - Enum2 = EnumStoredAsInt32.High, - Component = new UserComponent() - { - Property1 = "test1", - Property2 = "test2", - OtherComponent = new UserComponent2() - { - OtherProperty1 = "othertest1" - } - } - }, - new User("rahien", new DateTime(1998, 12, 31)) - { - Role = roles[1], - InvalidLoginAttempts = 5, - Enum1 = EnumStoredAsString.Small, - Component = new UserComponent() - { - Property2 = "test2" - } - }, - new User("nhibernate", new DateTime(2000, 1, 1)) - { - InvalidLoginAttempts = 6, - LastLoginDate = DateTime.Now.AddDays(-1), - Enum1 = EnumStoredAsString.Medium - } - }; - - var timesheets = new[] - { - new Timesheet - { - SubmittedDate = DateTime.Today, - Submitted = true - }, - new Timesheet - { - SubmittedDate = DateTime.Today.AddDays(-1), - Submitted = false, - Entries = new List<TimesheetEntry> - { - new TimesheetEntry - { - EntryDate = DateTime.Today, - NumberOfHours = 6, - Comments = "testing 123" - }, - new TimesheetEntry - { - EntryDate = DateTime.Today.AddDays(1), - NumberOfHours = 14 - } - } - }, - new Timesheet - { - SubmittedDate = DateTime.Now.AddDays(1), - Submitted = true, - Entries = new List<TimesheetEntry> - { - new TimesheetEntry - { - EntryDate = DateTime.Now.AddMinutes(20), - NumberOfHours = 4 - }, - new TimesheetEntry - { - EntryDate = DateTime.Now.AddMinutes(10), - NumberOfHours = 8, - Comments = "testing 456" - }, - new TimesheetEntry - { - EntryDate = DateTime.Now.AddMinutes(13), - NumberOfHours = 7 - }, - new TimesheetEntry - { - EntryDate = DateTime.Now.AddMinutes(45), - NumberOfHours = 38 - } - } - } - }; - - ((IList<User>)timesheets[0].Users).Add(users[0]); - ((IList<User>)timesheets[1].Users).Add(users[0]); - ((IList<User>)timesheets[0].Users).Add(users[1]); - - var animals = new Animal[] + protected override void OnTearDown() + { + if (_session.IsOpen) { - new Animal() { SerialNumber = "123", BodyWeight = 100 }, - new Lizard() { SerialNumber = "789", BodyWeight = 40, BodyTemperature = 14 }, - new Lizard() { SerialNumber = "1234", BodyWeight = 30, BodyTemperature = 18 }, - new Dog() { SerialNumber = "5678", BodyWeight = 156, BirthDate = new DateTime(1980, 07, 11) }, - new Dog() { SerialNumber = "9101", BodyWeight = 205, BirthDate = new DateTime(1980, 12, 13) }, - new Cat() { SerialNumber = "1121", BodyWeight = 115, Pregnant = true } - }; + _session.Close(); + } + } - animals[0].Children = new[] { animals[3], animals[4] }.ToList(); - animals[5].Father = animals[3]; - animals[5].Mother = animals[4]; - - animals[1].Children = new[] { animals[5] }.ToList(); - - foreach (Role role in roles) - session.Save(role); - - foreach (User user in users) - session.Save(user); - - foreach (Timesheet timesheet in timesheets) - session.Save(timesheet); - - foreach (Animal animal in animals) - session.Save(animal); - } - - private void CreatePatientData(ISession session) - { - State newYork = new State - { - Abbreviation = "NY", - FullName = "New York" - }; - State florida = new State - { - Abbreviation = "FL", - FullName = "Florida" - }; - - Physician drDobbs = new Physician - { - Name = "Dr Dobbs" - }; - Physician drWatson = new Physician - { - Name = "Dr Watson" - }; - - PatientRecord bobBarkerRecord = new PatientRecord - { - Name = new PatientName - { - FirstName = "Bob", - LastName = "Barker" - }, - Address = new PatientAddress - { - AddressLine1 = "123 Main St", - City = "New York", - State = newYork, - ZipCode = "10001" - }, - BirthDate = new DateTime(1930, 1, 1), - Gender = Gender.Male - }; - - PatientRecord johnDoeRecord1 = new PatientRecord - { - Name = new PatientName - { - FirstName = "John", - LastName = "Doe" - }, - Address = new PatientAddress - { - AddressLine1 = "123 Main St", - City = "Tampa", - State = florida, - ZipCode = "33602" - }, - BirthDate = new DateTime(1969, 1, 1), - Gender = Gender.Male - }; - - PatientRecord johnDoeRecord2 = new PatientRecord - { - Name = new PatientName - { - FirstName = "John", - LastName = "Doe" - }, - Address = new PatientAddress - { - AddressLine1 = "123 Main St", - AddressLine2 = "Apt 2", - City = "Tampa", - State = florida, - ZipCode = "33602" - }, - BirthDate = new DateTime(1969, 1, 1) - }; - - Patient bobBarker = new Patient(new[] { bobBarkerRecord }, false, drDobbs); - Patient johnDoe = new Patient(new[] { johnDoeRecord1, johnDoeRecord2 }, true, drWatson); - - session.Save(newYork); - session.Save(florida); - session.Save(drDobbs); - session.Save(drWatson); - session.Save(bobBarker); - session.Save(johnDoe); - } - - private void CreateNorthwindData(IStatelessSession session) - { - var shippers = new List<Shipper>(); - var shipper = new Shipper { ShipperId = 1, CompanyName = "Speedy Express", PhoneNumber = "(503) 555-9831", Reference = new Guid("356E4A7E-B027-4321-BA40-E2677E6502CF") }; session.Insert(shipper); shippers.Add(shipper); - shipper = new Shipper { ShipperId = 2, CompanyName = "United Package", PhoneNumber = "(503) 555-3199", Reference = new Guid("6DFCD0D7-4D2E-4525-A502-3EA9AA52E965") }; session.Insert(shipper); shippers.Add(shipper); - shipper = new Shipper { ShipperId = 3, CompanyName = "Federal Shipping", PhoneNumber = "(503) 555-9931", Reference = new Guid("716F114B-E253-4166-8C76-46E6F340B58F") }; session.Insert(shipper); shippers.Add(shipper); - - var categories = new List<ProductCategory>(); - var category = new ProductCategory { CategoryId = 1, Name = "Beverages", Description = "Soft drinks, coffees, teas, beers, and ales" }; session.Insert(category); categories.Add(category); - category = new ProductCategory { CategoryId = 2, Name = "Condiments", Description = "Sweet and savory sauces, relishes, spreads, and seasonings" }; session.Insert(category); categories.Add(category); - category = new ProductCategory { CategoryId = 3, Name = "Confections", Description = "Desserts, candies, and sweet breads" }; session.Insert(category); categories.Add(category); - category = new ProductCategory { CategoryId = 4, Name = "Dairy Products", Description = "Cheeses" }; session.Insert(category); categories.Add(category); - category = new ProductCategory { CategoryId = 5, Name = "Grains/Cereals", Description = "Breads, crackers, pasta, and cereal" }; session.Insert(category); categories.Add(category); - category = new ProductCategory { CategoryId = 6, Name = "Meat/Poultry", Description = "Prepared meats" }; session.Insert(category); categories.Add(category); - category = new ProductCategory { CategoryId = 7, Name = "Produce", Description = "Dried fruit and bean curd" }; session.Insert(category); categories.Add(category); - category = new ProductCategory { CategoryId = 8, Name = "Seafood", Description = "Seaweed and fish" }; session.Insert(category); categories.Add(category); - - var suppliers = new List<Supplier>(); - var supplier = new Supplier { SupplierId = 1, CompanyName = "Exotic Liquids", ContactName = "Charlotte Cooper", ContactTitle = "Purchasing Manager", HomePage = "", Address = new Address("49 Gilbert St.", "London", "", "EC1 4SD", "UK", "(171) 555-2222", "") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 2, CompanyName = "New Orleans Cajun Delights", ContactName = "Shelley Burke", ContactTitle = "Order Administrator", HomePage = "#CAJUN.HTM#", Address = new Address("P.O. Box 78934", "New Orleans", "LA", "70117", "USA", "(100) 555-4822", "") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 3, CompanyName = "Grandma Kelly's Homestead", ContactName = "Regina Murphy", ContactTitle = "Sales Representative", HomePage = "", Address = new Address("707 Oxford Rd.", "Ann Arbor", "MI", "48104", "USA", "(313) 555-5735", "(313) 555-3349") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 4, CompanyName = "Tokyo Traders", ContactName = "Yoshi Nagase", ContactTitle = "Marketing Manager", HomePage = "", Address = new Address("9-8 Sekimai Musashino-shi", "Tokyo", "", "100", "Japan", "(03) 3555-5011", "") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 5, CompanyName = "Cooperativa de Quesos 'Las Cabras'", ContactName = "Antonio del Valle Saavedra", ContactTitle = "Export Administrator", HomePage = "", Address = new Address("Calle del Rosal 4", "Oviedo", "Asturias", "33007", "Spain", "(98) 598 76 54", "") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 6, CompanyName = "Mayumi's", ContactName = "Mayumi Ohno", ContactTitle = "Marketing Representative", HomePage = "Mayumi's (on the World Wide Web)#http://www.microsoft.com/accessdev/sampleapps/mayumi.htm#", Address = new Address("92 Setsuko Chuo-ku", "Osaka", "", "545", "Japan", "(06) 431-7877", "") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 7, CompanyName = "Pavlova, Ltd.", ContactName = "Ian Devling", ContactTitle = "Marketing Manager", HomePage = "", Address = new Address("74 Rose St. Moonie Ponds", "Melbourne", "Victoria", "3058", "Australia", "(03) 444-2343", "(03) 444-6588") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 8, CompanyName = "Specialty Biscuits, Ltd.", ContactName = "Peter Wilson", ContactTitle = "Sales Representative", HomePage = "", Address = new Address("29 King's Way", "Manchester", "", "M14 GSD", "UK", "(161) 555-4448", "") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 9, CompanyName = "PB Knäckebröd AB", ContactName = "Lars Peterson", ContactTitle = "Sales Agent", HomePage = "", Address = new Address("Kaloadagatan 13", "Göteborg", "", "S-345 67", "Sweden", "031-987 65 43", "031-987 65 91") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 10, CompanyName = "Refrescos Americanas LTDA", ContactName = "Carlos Diaz", ContactTitle = "Marketing Manager", HomePage = "", Address = new Address("Av. das Americanas 12.890", "Sao Paulo", "", "5442", "Brazil", "(11) 555 4640", "") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 11, CompanyName = "Heli Süßwaren GmbH & Co. KG", ContactName = "Petra Winkler", ContactTitle = "Sales Manager", HomePage = "", Address = new Address("Tiergartenstraße 5", "Berlin", "", "10785", "Germany", "(010) 9984510", "") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 12, CompanyName = "Plutzer Lebensmittelgroßmärkte AG", ContactName = "Martin Bein", ContactTitle = "International Marketing Mgr.", HomePage = "Plutzer (on the World Wide Web)#http://www.microsoft.com/accessdev/sampleapps/plutzer.htm#", Address = new Address("Bogenallee 51", "Frankfurt", "", "60439", "Germany", "(069) 992755", "") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 13, CompanyName = "Nord-Ost-Fisch Handelsgesellschaft mbH", ContactName = "Sven Petersen", ContactTitle = "Coordinator Foreign Markets", HomePage = "", Address = new Address("Frahmredder 112a", "Cuxhaven", "", "27478", "Germany", "(04721) 8713", "(04721) 8714") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 14, CompanyName = "Formaggi Fortini s.r.l.", ContactName = "Elio Rossi", ContactTitle = "Sales Representative", HomePage = "#FORMAGGI.HTM#", Address = new Address("Viale Dante, 75", "Ravenna", "", "48100", "Italy", "(0544) 60323", "(0544) 60603") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 15, CompanyName = "Norske Meierier", ContactName = "Beate Vileid", ContactTitle = "Marketing Manager", HomePage = "", Address = new Address("Hatlevegen 5", "Sandvika", "", "1320", "Norway", "(0)2-953010", "") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 16, CompanyName = "Bigfoot Breweries", ContactName = "Cheryl Saylor", ContactTitle = "Regional Account Rep.", HomePage = "", Address = new Address("3400 - 8th Avenue Suite 210", "Bend", "OR", "97101", "USA", "(503) 555-9931", "") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 17, CompanyName = "Svensk Sjöföda AB", ContactName = "Michael Björn", ContactTitle = "Sales Representative", HomePage = "", Address = new Address("Brovallavägen 231", "Stockholm", "", "S-123 45", "Sweden", "08-123 45 67", "") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 18, CompanyName = "Aux joyeux ecclésiastiques", ContactName = "Guylène Nodier", ContactTitle = "Sales Manager", HomePage = "", Address = new Address("203, Rue des Francs-Bourgeois", "Paris", "", "75004", "France", "(1) 03.83.00.68", "(1) 03.83.00.62") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 19, CompanyName = "New England Seafood Cannery", ContactName = "Robb Merchant", ContactTitle = "Wholesale Account Agent", HomePage = "", Address = new Address("Order Processing Dept. 2100 Paul Revere Blvd.", "Boston", "MA", "02134", "USA", "(617) 555-3267", "(617) 555-3389") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 20, CompanyName = "Leka Trading", ContactName = "Chandra Leka", ContactTitle = "Owner", HomePage = "", Address = new Address("471 Serangoon Loop, Suite #402", "Singapore", "", "0512", "Singapore", "555-8787", "") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 21, CompanyName = "Lyngbysild", ContactName = "Niels Petersen", ContactTitle = "Sales Manager", HomePage = "", Address = new Address("Lyngbysild Fiskebakken 10", "Lyngby", "", "2800", "Denmark", "43844108", "43844115") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 22, CompanyName = "Zaanse Snoepfabriek", ContactName = "Dirk Luchte", ContactTitle = "Accounting Manager", HomePage = "", Address = new Address("Verkoop Rijnweg 22", "Zaandam", "", "9999 ZZ", "Netherlands", "(12345) 1212", "(12345) 1210") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 23, CompanyName = "Karkki Oy", ContactName = "Anne Heikkonen", ContactTitle = "Product Manager", HomePage = "", Address = new Address("Valtakatu 12", "Lappeenranta", "", "53120", "Finland", "(953) 10956", "") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 24, CompanyName = "G'day, Mate", ContactName = "Wendy Mackenzie", ContactTitle = "Sales Representative", HomePage = "G'day Mate (on the World Wide Web)#http://www.microsoft.com/accessdev/sampleapps/gdaymate.htm#", Address = new Address("170 Prince Edward Parade Hunter's Hill", "Sydney", "NSW", "2042", "Australia", "(02) 555-5914", "(02) 555-4873") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 25, CompanyName = "Ma Maison", ContactName = "Jean-Guy Lauzon", ContactTitle = "Marketing Manager", HomePage = "", Address = new Address("2960 Rue St. Laurent", "Montréal", "Québec", "H1J 1C3", "Canada", "(514) 555-9022", "") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 26, CompanyName = "Pasta Buttini s.r.l.", ContactName = "Giovanni Giudici", ContactTitle = "Order Administrator", HomePage = "", Address = new Address("Via dei Gelsomini, 153", "Salerno", "", "84100", "Italy", "(089) 6547665", "(089) 6547667") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 27, CompanyName = "Escargots Nouveaux", ContactName = "Marie Delamare", ContactTitle = "Sales Manager", HomePage = "", Address = new Address("22, rue H. Voiron", "Montceau", "", "71300", "France", "85.57.00.07", "") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 28, CompanyName = "Gai pâturage", ContactName = "Eliane Noz", ContactTitle = "Sales Representative", HomePage = "", Address = new Address("Bat. B 3, rue des Alpes", "Annecy", "", "74000", "France", "38.76.98.06", "38.76.98.58") }; session.Insert(supplier); suppliers.Add(supplier); - supplier = new Supplier { SupplierId = 29, CompanyName = "Forêts d'érables", ContactName = "Chantal Goulet", ContactTitle = "Accounting Manager", HomePage = "", Address = new Address("148 rue Chasseur", "Ste-Hyacinthe", "Québec", "J2S 7S8", "Canada", "(514) 555-2955", "(514) 555-2921") }; session.Insert(supplier); suppliers.Add(supplier); - - var employees = new List<Employee>(); - var employee = new Employee { EmployeeId = 1, LastName = "Davolio", FirstName = "Nancy", Title = "Sales Representative", TitleOfCourtesy = "Ms.", BirthDate = DateTime.Parse("Dec 8 1948 12:00AM"), HireDate = DateTime.Parse("May 1 1992 12:00AM"), Address = new Address("507 - 20th Ave. E.Apt. 2A", "Seattle", "WA", "98122", "USA", "(206) 555-9857", null), Extension = "5467", Notes = "Education includes a BA in psychology from Colorado State University in 1970. She also completed 'The Art of the Cold Call.' Nancy is a member of Toastmasters International." }; session.Insert(employee); employees.Add(employee); - employee = new Employee { EmployeeId = 2, LastName = "Fuller", FirstName = "Andrew", Title = "Vice President, Sales", TitleOfCourtesy = "Dr.", BirthDate = DateTime.Parse("Feb 19 1952 12:00AM"), HireDate = DateTime.Parse("Aug 14 1992 12:00AM"), Address = new Address("908 W. Capital Way", "Tacoma", "WA", "98401", "USA", "(206) 555-9482", null), Extension = "3457", Notes = "Andrew received his BTS commercial in 1974 and a Ph.D. in international marketing from the University of Dallas in 1981. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager in January 1992 and to vice president of sales in March 1993. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association." }; session.Insert(employee); employees.Add(employee); - employee = new Employee { EmployeeId = 3, LastName = "Leverling", FirstName = "Janet", Title = "Sales Representative", TitleOfCourtesy = "Ms.", BirthDate = DateTime.Parse("Aug 30 1963 12:00AM"), HireDate = DateTime.Parse("Apr 1 1992 12:00AM"), Address = new Address("722 Moss Bay Blvd.", "Kirkland", "WA", "98033", "USA", "(206) 555-3412", null), Extension = "3355", Notes = "Janet has a BS degree in chemistry from Boston College (1984). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate in 1991 and promoted to sales representative in February 1992." }; session.Insert(employee); employees.Add(employee); - employee = new Employee { EmployeeId = 4, LastName = "Peacock", FirstName = "Margaret", Title = "Sales Representative", TitleOfCourtesy = "Mrs.", BirthDate = DateTime.Parse("Sep 19 1937 12:00AM"), HireDate = DateTime.Parse("May 3 1993 12:00AM"), Address = new Address("4110 Old Redmond Rd.", "Redmond", "WA", "98052", "USA", "(206) 555-8122", null), Extension = "5176", Notes = "Margaret holds a BA in English literature from Concordia College (1958) and an MA from the American Institute of Culinary Arts (1966). She was assigned to the London office temporarily from July through November 1992." }; session.Insert(employee); employees.Add(employee); - employee = new Employee { EmployeeId = 5, LastName = "Buchanan", FirstName = "Steven", Title = "Sales Manager", TitleOfCourtesy = "Mr.", BirthDate = DateTime.Parse("Mar 4 1955 12:00AM"), HireDate = DateTime.Parse("Oct 17 1993 12:00AM"), Address = new Address("14 Garrett Hill", "London", "", "SW1 8JR", "UK", "(71) 555-4848", null), Extension = "3453", Notes = "Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree in 1976. Upon joining the company as a sales representative in 1992, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London. He was promoted to sales manager in March 1993. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management.' He is fluent in French." }; session.Insert(employee); employees.Add(employee); - employee = new Employee { EmployeeId = 6, LastName = "Suyama", FirstName = "Michael", Title = "Sales Representative", TitleOfCourtesy = "Mr.", BirthDate = DateTime.Parse("Jul 2 1963 12:00AM"), HireDate = DateTime.Parse("Oct 17 1993 12:00AM"), Address = new Address("Coventry HouseMiner Rd.", "London", "", "EC2 7JR", "UK", "(71) 555-7773", null), Extension = "428", Notes = "Michael is a graduate of Sussex University (MA, economics, 1983) and the University of California at Los Angeles (MBA, marketing, 1986). He has also taken the courses 'Multi-Cultural Selling' and 'Time Management for the Sales Professional.' He is fluent in Japanese and can read and write French, Portuguese, and Spanish." }; session.Insert(employee); employees.Add(employee); - employee = new Employee { EmployeeId = 7, LastName = "King", FirstName = "Robert", Title = "Sales Representative", TitleOfCourtesy = "Mr.", BirthDate = DateTime.Parse("May 29 1960 12:00AM"), HireDate = DateTime.Parse("Jan 2 1994 12:00AM"), Address = new Address("Edgeham HollowWinchester Way", "London", "", "RG1 9SP", "UK", "(71) 555-5598", null), Extension = "465", Notes = "Robert King served in the Peace Corps and traveled extensively before completing his degree in English at the University of Michigan in 1992, the year he joined the company. After completing a course entitled 'Selling in Europe,' he was transferred to the London office in March 1993." }; session.Insert(employee); employees.Add(employee); - employee = new Employee { EmployeeId = 8, LastName = "Callahan", FirstName = "Laura", Title = "Inside Sales Coordinator", TitleOfCourtesy = "Ms.", BirthDate = DateTime.Parse("Jan 9 1958 12:00AM"), HireDate = DateTime.Parse("Mar 5 1994 12:00AM"), Address = new Address("4726 - 11th Ave. N.E.", "Seattle", "WA", "98105", "USA", "(206) 555-1189", null), Extension = "2344", Notes = "Laura received a BA in psychology from the University of Washington. She has also completed a course in business French. She reads and writes French." }; session.Insert(employee); employees.Add(employee); - employee = new Employee { EmployeeId = 9, LastName = "Dodsworth", FirstName = "Anne", Title = "Sales Representative", TitleOfCourtesy = "Ms.", BirthDate = DateTime.Parse("Jan 27 1966 12:00AM"), HireDate = DateTime.Parse("Nov 15 1994 12:00AM"), Address = new Address("7 Houndstooth Rd.", "London", "", "WG2 7LT", "UK", "(71) 555-4444", null), Extension = "452", Notes = "Anne has a BA degree in English from St. Lawrence College. She is fluent in French and German." }; session.Insert(employee); employees.Add(employee); - - employees.Where(e => e.LastName == "Davolio").First().Superior = employees.Where(e => e.LastName == "Fuller").First(); - employees.Where(e => e.LastName == "Leverling").First().Superior = employees.Where(e => e.LastName == "Fuller").First(); - employees.Where(e => e.LastName == "Peacock").First().Superior = employees.Where(e => e.LastName == "Fuller").First(); - employees.Where(e => e.LastName == "Buchanan").First().Superior = employees.Where(e => e.LastName == "Fuller").First(); - employees.Where(e => e.LastName == "Suyama").First().Superior = employees.Where(e => e.LastName == "Buchanan").First(); - employees.Where(e => e.LastName == "King").First().Superior = employees.Where(e => e.LastName == "Buchanan").First(); - employees.Where(e => e.LastName == "Callahan").First().Superior = employees.Where(e => e.LastName == "Fuller").First(); - employees.Where(e => e.LastName == "Dodsworth").First().Superior = employees.Where(e => e.LastName == "Buchanan").First(); - - var customers = new List<Customer>(); - var customer = new Customer { CustomerId = "ALFKI", CompanyName = "Alfreds Futterkiste", ContactName = "Maria Anders", ContactTitle = "Sales Representative", Address = new Address("Obere Str. 57", "Berlin", "", "12209", "Germany", "030-0074321", "030-0076545") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "ANATR", CompanyName = "Ana Trujillo Emparedados y helados", ContactName = "Ana Trujillo", ContactTitle = "Owner", Address = new Address("Avda. de la Constitución 2222", "México D.F.", "", "05021", "Mexico", "(5) 555-4729", "(5) 555-3745") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "ANTON", CompanyName = "Antonio Moreno Taquería", ContactName = "Antonio Moreno", ContactTitle = "Owner", Address = new Address("Mataderos 2312", "México D.F.", "", "05023", "Mexico", "(5) 555-3932", "") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "AROUT", CompanyName = "Around the Horn", ContactName = "Thomas Hardy", ContactTitle = "Sales Representative", Address = new Address("120 Hanover Sq.", "London", "", "WA1 1DP", "UK", "(171) 555-7788", "(171) 555-6750") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "BERGS", CompanyName = "Berglunds snabbköp", ContactName = "Christina Berglund", ContactTitle = "Order Administrator", Address = new Address("Berguvsvägen 8", "Luleå", "", "S-958 22", "Sweden", "0921-12 34 65", "0921-12 34 67") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "BLAUS", CompanyName = "Blauer See Delikatessen", ContactName = "Hanna Moos", ContactTitle = "Sales Representative", Address = new Address("Forsterstr. 57", "Mannheim", "", "68306", "Germany", "0621-08460", "0621-08924") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "BLONP", CompanyName = "Blondesddsl père et fils", ContactName = "Frédérique Citeaux", ContactTitle = "Marketing Manager", Address = new Address("24, place Kléber", "Strasbourg", "", "67000", "France", "88.60.15.31", "88.60.15.32") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "BOLID", CompanyName = "Bólido Comidas preparadas", ContactName = "Martín Sommer", ContactTitle = "Owner", Address = new Address("C/ Araquil, 67", "Madrid", "", "28023", "Spain", "(91) 555 22 82", "(91) 555 91 99") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "BONAP", CompanyName = "Bon app'", ContactName = "Laurence Lebihan", ContactTitle = "Owner", Address = new Address("12, rue des Bouchers", "Marseille", "", "13008", "France", "91.24.45.40", "91.24.45.41") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "BOTTM", CompanyName = "Bottom-Dollar Markets", ContactName = "Elizabeth Lincoln", ContactTitle = "Accounting Manager", Address = new Address("23 Tsawassen Blvd.", "Tsawassen", "BC", "T2F 8M4", "Canada", "(604) 555-4729", "(604) 555-3745") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "BSBEV", CompanyName = "B's Beverages", ContactName = "Victoria Ashworth", ContactTitle = "Sales Representative", Address = new Address("Fauntleroy Circus", "London", "", "EC2 5NT", "UK", "(171) 555-1212", "") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "CACTU", CompanyName = "Cactus Comidas para llevar", ContactName = "Patricio Simpson", ContactTitle = "Sales Agent", Address = new Address("Cerrito 333", "Buenos Aires", "", "1010", "Argentina", "(1) 135-5555", "(1) 135-4892") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "CENTC", CompanyName = "Centro comercial Moctezuma", ContactName = "Francisco Chang", ContactTitle = "Marketing Manager", Address = new Address("Sierras de Granada 9993", "México D.F.", "", "05022", "Mexico", "(5) 555-3392", "(5) 555-7293") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "CHOPS", CompanyName = "Chop-suey Chinese", ContactName = "Yang Wang", ContactTitle = "Owner", Address = new Address("Hauptstr. 29", "Bern", "", "3012", "Switzerland", "0452-076545", "") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "COMMI", CompanyName = "Comércio Mineiro", ContactName = "Pedro Afonso", ContactTitle = "Sales Associate", Address = new Address("Av. dos Lusíadas, 23", "Sao Paulo", "SP", "05432-043", "Brazil", "(11) 555-7647", "") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "CONSH", CompanyName = "Consolidated Holdings", ContactName = "Elizabeth Brown", ContactTitle = "Sales Representative", Address = new Address("Berkeley Gardens 12 Brewery", "London", "", "WX1 6LT", "UK", "(171) 555-2282", "(171) 555-9199") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "DRACD", CompanyName = "Drachenblut Delikatessen", ContactName = "Sven Ottlieb", ContactTitle = "Order Administrator", Address = new Address("Walserweg 21", "Aachen", "", "52066", "Germany", "0241-039123", "0241-059428") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "DUMON", CompanyName = "Du monde entier", ContactName = "Janine Labrune", ContactTitle = "Owner", Address = new Address("67, rue des Cinquante Otages", "Nantes", "", "44000", "France", "40.67.88.88", "40.67.89.89") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "EASTC", CompanyName = "Eastern Connection", ContactName = "Ann Devon", ContactTitle = "Sales Agent", Address = new Address("35 King George", "London", "", "WX3 6FW", "UK", "(171) 555-0297", "(171) 555-3373") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "ERNSH", CompanyName = "Ernst Handel", ContactName = "Roland Mendel", ContactTitle = "Sales Manager", Address = new Address("Kirchgasse 6", "Graz", "", "8010", "Austria", "7675-3425", "7675-3426") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "FAMIA", CompanyName = "Familia Arquibaldo", ContactName = "Aria Cruz", ContactTitle = "Marketing Assistant", Address = new Address("Rua Orós, 92", "Sao Paulo", "SP", "05442-030", "Brazil", "(11) 555-9857", "") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "FISSA", CompanyName = "FISSA Fabrica Inter. Salchichas S.A.", ContactName = "Diego Roel", ContactTitle = "Accounting Manager", Address = new Address("C/ Moralzarzal, 86", "Madrid", "", "28034", "Spain", "(91) 555 94 44", "(91) 555 55 93") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "FOLIG", CompanyName = "Folies gourmandes", ContactName = "Martine Rancé", ContactTitle = "Assistant Sales Agent", Address = new Address("184, chaussée de Tournai", "Lille", "", "59000", "France", "20.16.10.16", "20.16.10.17") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "FOLKO", CompanyName = "Folk och fä HB", ContactName = "Maria Larsson", ContactTitle = "Owner", Address = new Address("Åkergatan 24", "Bräcke", "", "S-844 67", "Sweden", "0695-34 67 21", "") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "FRANK", CompanyName = "Frankenversand", ContactName = "Peter Franken", ContactTitle = "Marketing Manager", Address = new Address("Berliner Platz 43", "München", "", "80805", "Germany", "089-0877310", "089-0877451") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "FRANR", CompanyName = "France restauration", ContactName = "Carine Schmitt", ContactTitle = "Marketing Manager", Address = new Address("54, rue Royale", "Nantes", "", "44000", "France", "40.32.21.21", "40.32.21.20") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "FRANS", CompanyName = "Franchi S.p.A.", ContactName = "Paolo Accorti", ContactTitle = "Sales Representative", Address = new Address("Via Monte Bianco 34", "Torino", "", "10100", "Italy", "011-4988260", "011-4988261") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "FURIB", CompanyName = "Furia Bacalhau e Frutos do Mar", ContactName = "Lino Rodriguez", ContactTitle = "Sales Manager", Address = new Address("Jardim das rosas n. 32", "Lisboa", "", "1675", "Portugal", "(1) 354-2534", "(1) 354-2535") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "GALED", CompanyName = "Galería del gastrónomo", ContactName = "Eduardo Saavedra", ContactTitle = "Marketing Manager", Address = new Address("Rambla de Cataluña, 23", "Barcelona", "", "08022", "Spain", "(93) 203 4560", "(93) 203 4561") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "GODOS", CompanyName = "Godos Cocina Típica", ContactName = "José Pedro Freyre", ContactTitle = "Sales Manager", Address = new Address("C/ Romero, 33", "Sevilla", "", "41101", "Spain", "(95) 555 82 82", "") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "GOURL", CompanyName = "Gourmet Lanchonetes", ContactName = "André Fonseca", ContactTitle = "Sales Associate", Address = new Address("Av. Brasil, 442", "Campinas", "SP", "04876-786", "Brazil", "(11) 555-9482", "") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "GREAL", CompanyName = "Great Lakes Food Market", ContactName = "Howard Snyder", ContactTitle = "Marketing Manager", Address = new Address("2732 Baker Blvd.", "Eugene", "OR", "97403", "USA", "(503) 555-7555", "") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "GROSR", CompanyName = "GROSELLA-Restaurante", ContactName = "Manuel Pereira", ContactTitle = "Owner", Address = new Address("5ª Ave. Los Palos Grandes", "Caracas", "DF", "1081", "Venezuela", "(2) 283-2951", "(2) 283-3397") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "HANAR", CompanyName = "Hanari Carnes", ContactName = "Mario Pontes", ContactTitle = "Accounting Manager", Address = new Address("Rua do Paço, 67", "Rio de Janeiro", "RJ", "05454-876", "Brazil", "(21) 555-0091", "(21) 555-8765") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "HILAA", CompanyName = "HILARION-Abastos", ContactName = "Carlos Hernández", ContactTitle = "Sales Representative", Address = new Address("Carrera 22 con Ave. Carlos Soublette #8-35", "San Cristóbal", "Táchira", "5022", "Venezuela", "(5) 555-1340", "(5) 555-1948") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "HUNGC", CompanyName = "Hungry Coyote Import Store", ContactName = "Yoshi Latimer", ContactTitle = "Sales Representative", Address = new Address("City Center Plaza 516 Main St.", "Elgin", "OR", "97827", "USA", "(503) 555-6874", "(503) 555-2376") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "HUNGO", CompanyName = "Hungry Owl All-Night Grocers", ContactName = "Patricia McKenna", ContactTitle = "Sales Associate", Address = new Address("8 Johnstown Road", "Cork", "Co. Cork", "", "Ireland", "2967 542", "2967 3333") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "ISLAT", CompanyName = "Island Trading", ContactName = "Helen Bennett", ContactTitle = "Marketing Manager", Address = new Address("Garden House Crowther Way", "Cowes", "Isle of Wight", "PO31 7PJ", "UK", "(198) 555-8888", "") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "KOENE", CompanyName = "Königlich Essen", ContactName = "Philip Cramer", ContactTitle = "Sales Associate", Address = new Address("Maubelstr. 90", "Brandenburg", "", "14776", "Germany", "0555-09876", "") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "LACOR", CompanyName = "La corne d'abondance", ContactName = "Daniel Tonini", ContactTitle = "Sales Representative", Address = new Address("67, avenue de l'Europe", "Versailles", "", "78000", "France", "30.59.84.10", "30.59.85.11") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "LAMAI", CompanyName = "La maison d'Asie", ContactName = "Annette Roulet", ContactTitle = "Sales Manager", Address = new Address("1 rue Alsace-Lorraine", "Toulouse", "", "31000", "France", "61.77.61.10", "61.77.61.11") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "LAUGB", CompanyName = "Laughing Bacchus Wine Cellars", ContactName = "Yoshi Tannamuri", ContactTitle = "Marketing Assistant", Address = new Address("1900 Oak St.", "Vancouver", "BC", "V3F 2K1", "Canada", "(604) 555-3392", "(604) 555-7293") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "LAZYK", CompanyName = "Lazy K Kountry Store", ContactName = "John Steel", ContactTitle = "Marketing Manager", Address = new Address("12 Orchestra Terrace", "Walla Walla", "WA", "99362", "USA", "(509) 555-7969", "(509) 555-6221") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "LEHMS", CompanyName = "Lehmanns Marktstand", ContactName = "Renate Messner", ContactTitle = "Sales Representative", Address = new Address("Magazinweg 7", "Frankfurt a.M.", "", "60528", "Germany", "069-0245984", "069-0245874") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "LETSS", CompanyName = "Let's Stop N Shop", ContactName = "Jaime Yorres", ContactTitle = "Owner", Address = new Address("87 Polk St. Suite 5", "San Francisco", "CA", "94117", "USA", "(415) 555-5938", "") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "LILAS", CompanyName = "LILA-Supermercado", ContactName = "Carlos González", ContactTitle = "Accounting Manager", Address = new Address("Carrera 52 con Ave. Bolívar #65-98 Llano Largo", "Barquisimeto", "Lara", "3508", "Venezuela", "(9) 331-6954", "(9) 331-7256") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "LINOD", CompanyName = "LINO-Delicateses", ContactName = "Felipe Izquierdo", ContactTitle = "Owner", Address = new Address("Ave. 5 de Mayo Porlamar", "I. de Margarita", "Nueva Esparta", "4980", "Venezuela", "(8) 34-56-12", "(8) 34-93-93") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "LONEP", CompanyName = "Lonesome Pine Restaurant", ContactName = "Fran Wilson", ContactTitle = "Sales Manager", Address = new Address("89 Chiaroscuro Rd.", "Portland", "OR", "97219", "USA", "(503) 555-9573", "(503) 555-9646") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "MAGAA", CompanyName = "Magazzini Alimentari Riuniti", ContactName = "Giovanni Rovelli", ContactTitle = "Marketing Manager", Address = new Address("Via Ludovico il Moro 22", "Bergamo", "", "24100", "Italy", "035-640230", "035-640231") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "MAISD", CompanyName = "Maison Dewey", ContactName = "Catherine Dewey", ContactTitle = "Sales Agent", Address = new Address("Rue Joseph-Bens 532", "Bruxelles", "", "B-1180", "Belgium", "(02) 201 24 67", "(02) 201 24 68") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "MEREP", CompanyName = "Mère Paillarde", ContactName = "Jean Fresnière", ContactTitle = "Marketing Assistant", Address = new Address("43 rue St. Laurent", "Montréal", "Québec", "H1J 1C3", "Canada", "(514) 555-8054", "(514) 555-8055") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "MORGK", CompanyName = "Morgenstern Gesundkost", ContactName = "Alexander Feuer", ContactTitle = "Marketing Assistant", Address = new Address("Heerstr. 22", "Leipzig", "", "04179", "Germany", "0342-023176", "") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "NORTS", CompanyName = "North/South", ContactName = "Simon Crowther", ContactTitle = "Sales Associate", Address = new Address("South House 300 Queensbridge", "London", "", "SW7 1RZ", "UK", "(171) 555-7733", "(171) 555-2530") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "OCEAN", CompanyName = "Océano Atlántico Ltda.", ContactName = "Yvonne Moncada", ContactTitle = "Sales Agent", Address = new Address("Ing. Gustavo Moncada 8585 Piso 20-A", "Buenos Aires", "", "1010", "Argentina", "(1) 135-5333", "(1) 135-5535") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "OLDWO", CompanyName = "Old World Delicatessen", ContactName = "Rene Phillips", ContactTitle = "Sales Representative", Address = new Address("2743 Bering St.", "Anchorage", "AK", "99508", "USA", "(907) 555-7584", "(907) 555-2880") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "OTTIK", CompanyName = "Ottilies Käseladen", ContactName = "Henriette Pfalzheim", ContactTitle = "Owner", Address = new Address("Mehrheimerstr. 369", "Köln", "", "50739", "Germany", "0221-0644327", "0221-0765721") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "PARIS", CompanyName = "Paris spécialités", ContactName = "Marie Bertrand", ContactTitle = "Owner", Address = new Address("265, boulevard Charonne", "Paris", "", "75012", "France", "(1) 42.34.22.66", "(1) 42.34.22.77") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "PERIC", CompanyName = "Pericles Comidas clásicas", ContactName = "Guillermo Fernández", ContactTitle = "Sales Representative", Address = new Address("Calle Dr. Jorge Cash 321", "México D.F.", "", "05033", "Mexico", "(5) 552-3745", "(5) 545-3745") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "PICCO", CompanyName = "Piccolo und mehr", ContactName = "Georg Pipps", ContactTitle = "Sales Manager", Address = new Address("Geislweg 14", "Salzburg", "", "5020", "Austria", "6562-9722", "6562-9723") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "PRINI", CompanyName = "Princesa Isabel Vinhos", ContactName = "Isabel de Castro", ContactTitle = "Sales Representative", Address = new Address("Estrada da saúde n. 58", "Lisboa", "", "1756", "Portugal", "(1) 356-5634", "") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "QUEDE", CompanyName = "Que Delícia", ContactName = "Bernardo Batista", ContactTitle = "Accounting Manager", Address = new Address("Rua da Panificadora, 12", "Rio de Janeiro", "RJ", "02389-673", "Brazil", "(21) 555-4252", "(21) 555-4545") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "QUEEN", CompanyName = "Queen Cozinha", ContactName = "Lúcia Carvalho", ContactTitle = "Marketing Assistant", Address = new Address("Alameda dos Canàrios, 891", "Sao Paulo", "SP", "05487-020", "Brazil", "(11) 555-1189", "") }; session.Insert(customer); customers.Add(customer); - customer = new Customer { CustomerId = "QUICK", CompanyName = "QUICK-Stop", ContactName = "Horst Kloss", ContactTitle = "Accounting Manager", Address = new Address("Taucherstraße 10", "Cunewalde", "", "01307", "Germany", "0372-035188", "") }; session.Insert(custom... [truncated message content] |
From: <jul...@us...> - 2010-07-18 15:05:54
|
Revision: 5008 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5008&view=rev Author: julian-maughan Date: 2010-07-18 15:05:47 +0000 (Sun, 18 Jul 2010) Log Message: ----------- Added Hibernate component tests, and contributed test for issue NH-2061 (Merge operation causes exception for null components that contain many-to-many relations) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/ExpressionTest/QueryByExampleTest.cs trunk/nhibernate/src/NHibernate.Test/Legacy/SQLLoaderTest.cs trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/Component/ trunk/nhibernate/src/NHibernate.Test/Component/Basic/ trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs trunk/nhibernate/src/NHibernate.Test/Component/Basic/Employee.cs trunk/nhibernate/src/NHibernate.Test/Component/Basic/OptionalComponent.cs trunk/nhibernate/src/NHibernate.Test/Component/Basic/Person.cs trunk/nhibernate/src/NHibernate.Test/Component/Basic/User.cs trunk/nhibernate/src/NHibernate.Test/Component/Basic/User.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Model.cs Added: trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs 2010-07-18 15:05:47 UTC (rev 5008) @@ -0,0 +1,417 @@ +using System; +using System.Collections.Generic; +using NHibernate; +using NHibernate.Cfg; +using NHibernate.Criterion; +using NHibernate.Transaction; +using NUnit.Framework; + +namespace NHibernate.Test.Component.Basic +{ + [TestFixture] + public class ComponentTest : TestCase + { + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + protected override System.Collections.IList Mappings + { + get { return new string[] { "Component.Basic.User.hbm.xml" }; } + } + + protected override void Configure(Configuration configuration) + { + configuration.SetProperty(NHibernate.Cfg.Environment.GenerateStatistics, "true"); + } + + protected override void OnTearDown() + { + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Delete("from User"); + s.Delete("from Employee"); + t.Commit(); + } + + base.OnTearDown(); + } + + [Test] + public void TestUpdateFalse() + { + User u; + + sessions.Statistics.Clear(); + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + u = new User("gavin", "secret", new Person("Gavin King", new DateTime(1999, 12, 31), "Karbarook Ave")); + s.Persist(u); + s.Flush(); + u.Person.Name = "XXXXYYYYY"; + t.Commit(); + s.Close(); + } + + Assert.That(sessions.Statistics.EntityInsertCount, Is.EqualTo(1)); + Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(0)); + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + u = (User)s.Get(typeof(User), "gavin"); + Assert.That(u.Person.Name, Is.EqualTo("Gavin King")); + s.Delete(u); + t.Commit(); + s.Close(); + } + + Assert.That(sessions.Statistics.EntityDeleteCount, Is.EqualTo(1)); + } + + [Test] + public void TestComponent() + { + User u; + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + u = new User("gavin", "secret", new Person("Gavin King", new DateTime(1999, 12, 31), "Karbarook Ave")); + s.Persist(u); + s.Flush(); + u.Person.ChangeAddress("Phipps Place"); + t.Commit(); + } + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + u = (User)s.Get(typeof(User), "gavin"); + Assert.That(u.Person.Address, Is.EqualTo("Phipps Place")); + Assert.That(u.Person.PreviousAddress, Is.EqualTo("Karbarook Ave")); + Assert.That(u.Person.Yob, Is.EqualTo(u.Person.Dob.Year)); + u.Password = "$ecret"; + t.Commit(); + } + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + u = (User)s.Get(typeof(User), "gavin"); + Assert.That(u.Person.Address, Is.EqualTo("Phipps Place")); + Assert.That(u.Person.PreviousAddress, Is.EqualTo("Karbarook Ave")); + Assert.That(u.Password, Is.EqualTo("$ecret")); + s.Delete(u); + t.Commit(); + } + } + + [Test] + public void TestComponentStateChangeAndDirtiness() + { + // test for HHH-2366 + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + User u = new User("steve", "hibernater", new Person( "Steve Ebersole", new DateTime(1999, 12, 31), "Main St")); + s.Persist(u); + s.Flush(); + long intialUpdateCount = sessions.Statistics.EntityUpdateCount; + u.Person.Address = "Austin"; + s.Flush(); + Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(intialUpdateCount + 1)); + intialUpdateCount = sessions.Statistics.EntityUpdateCount; + u.Person.Address = "Cedar Park"; + s.Flush(); + Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(intialUpdateCount + 1)); + s.Delete(u); + t.Commit(); + s.Close(); + } + } + + [Test] + [Ignore("Ported from Hibernate. Read properties not supported in NH yet.")] + public void TestCustomColumnReadAndWrite() + { + const double HEIGHT_INCHES = 73; + const double HEIGHT_CENTIMETERS = HEIGHT_INCHES * 2.54d; + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + User u = new User("steve", "hibernater", new Person( "Steve Ebersole", new DateTime(1999, 12, 31), "Main St")); + u.Person.HeightInches = HEIGHT_INCHES; + s.Persist(u); + s.Flush(); + + // Test value conversion during insert + double heightViaSql = (double)s.CreateSQLQuery("select height_centimeters from t_user where t_user.username='steve'").UniqueResult(); + Assert.That(heightViaSql, Is.EqualTo(HEIGHT_CENTIMETERS).Within(0.01d)); + + // Test projection + double heightViaHql = (double)s.CreateQuery("select u.Person.HeightInches from User u where u.Id = 'steve'").UniqueResult(); + Assert.That(heightViaHql, Is.EqualTo(HEIGHT_INCHES).Within(0.01d)); + + // Test restriction and entity load via criteria + u = (User)s.CreateCriteria(typeof(User)) + .Add(Restrictions.Between("Person.HeightInches", HEIGHT_INCHES - 0.01d, HEIGHT_INCHES + 0.01d)) + .UniqueResult(); + Assert.That(u.Person.HeightInches, Is.EqualTo(HEIGHT_INCHES).Within(0.01d)); + + // Test predicate and entity load via HQL + u = (User)s.CreateQuery("from User u where u.Person.HeightInches between ? and ?") + .SetDouble(0, HEIGHT_INCHES - 0.01d) + .SetDouble(1, HEIGHT_INCHES + 0.01d) + .UniqueResult(); + + Assert.That(u.Person.HeightInches, Is.EqualTo(HEIGHT_INCHES).Within(0.01d)); + + // Test update + u.Person.HeightInches = 1; + s.Flush(); + heightViaSql = (double)s.CreateSQLQuery("select height_centimeters from t_user where t_user.username='steve'").UniqueResult(); + Assert.That(heightViaSql, Is.EqualTo(2.54d).Within(0.01d)); + s.Delete(u); + t.Commit(); + s.Close(); + } + } + + [Test] + [Ignore("Ported from Hibernate - failing in NH")] + public void TestComponentQueries() + { + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + Employee emp = new Employee(); + emp.HireDate = new DateTime(1999, 12, 31); + emp.Person = new Person(); + emp.Person.Name = "steve"; + emp.Person.Dob = new DateTime(1999, 12, 31); + s.Save(emp); + + s.CreateQuery("from Employee e where e.Person = :p and 1=1 and 2=2").SetParameter("p", emp.Person).List(); + s.CreateQuery("from Employee e where :p = e.Person").SetParameter("p", emp.Person).List(); + s.CreateQuery("from Employee e where e.Person = ('steve', current_timestamp)").List(); + + s.Delete( emp ); + t.Commit(); + s.Close(); + } + } + + [Test] + public void TestComponentFormulaQuery() + { + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.CreateQuery("from User u where u.Person.Yob = 1999").List(); + s.CreateCriteria(typeof(User)) + .Add(Property.ForName("Person.Yob").Between(1999, 2002)) + .List(); + + if (Dialect.SupportsRowValueConstructorSyntax) + { + s.CreateQuery("from User u where u.Person = ('gavin', :dob, 'Peachtree Rd', 'Karbarook Ave', 1974, 'Peachtree Rd')") + .SetDateTime("dob", new DateTime(1974, 3, 25)).List(); + s.CreateQuery("from User where Person = ('gavin', :dob, 'Peachtree Rd', 'Karbarook Ave', 1974, 'Peachtree Rd')") + .SetDateTime("dob", new DateTime(1974, 3, 25)).List(); + } + t.Commit(); + s.Close(); + } + } + + [Test] + public void TestNamedQuery() + { + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.GetNamedQuery("userNameIn") + .SetParameterList( "nameList", new object[] {"1ovthafew", "turin", "xam"} ) + .List(); + t.Commit(); + s.Close(); + } + } + + [Test] + public void TestMergeComponent() + { + Employee emp = null; + IEnumerator<Employee> enumerator = null; + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = new Employee(); + emp.HireDate = new DateTime(1999, 12, 31); + emp.Person = new Person(); + emp.Person.Name = "steve"; + emp.Person.Dob = new DateTime(1999, 12, 31); + s.Persist(emp); + t.Commit(); + s.Close(); + } + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = (Employee)s.Get(typeof(Employee), emp.Id); + t.Commit(); + s.Close(); + } + + Assert.That(emp.OptionalComponent, Is.Null); + + emp.OptionalComponent = new OptionalComponent(); + emp.OptionalComponent.Value1 = "emp-value1"; + emp.OptionalComponent.Value2 = "emp-value2"; + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = (Employee)s.Merge(emp); + t.Commit(); + s.Close(); + } + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = (Employee)s.Get(typeof(Employee), emp.Id); + t.Commit(); + s.Close(); + } + + Assert.That(emp.OptionalComponent.Value1, Is.EqualTo("emp-value1")); + Assert.That(emp.OptionalComponent.Value2, Is.EqualTo("emp-value2")); + + emp.OptionalComponent.Value1 = null; + emp.OptionalComponent.Value2 = null; + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = (Employee)s.Merge(emp); + t.Commit(); + s.Close(); + } + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = (Employee)s.Get(typeof(Employee), emp.Id); + NHibernateUtil.Initialize(emp.DirectReports); + t.Commit(); + s.Close(); + } + + Assert.That(emp.OptionalComponent, Is.Null); + + Employee emp1 = new Employee(); + emp1.HireDate = new DateTime(1999, 12, 31); + emp1.Person = new Person(); + emp1.Person.Name = "bozo"; + emp1.Person.Dob = new DateTime(1999, 12, 31); + emp.DirectReports.Add(emp1); + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = (Employee)s.Merge(emp); + t.Commit(); + s.Close(); + } + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = (Employee)s.Get(typeof(Employee), emp.Id); + NHibernateUtil.Initialize(emp.DirectReports); + t.Commit(); + s.Close(); + } + + Assert.That(emp.DirectReports.Count, Is.EqualTo(1)); + + enumerator = emp.DirectReports.GetEnumerator(); + enumerator.MoveNext(); + emp1 = (Employee)enumerator.Current; + Assert.That(emp1.OptionalComponent, Is.Null); + + emp1.OptionalComponent = new OptionalComponent(); + emp1.OptionalComponent.Value1 = "emp1-value1"; + emp1.OptionalComponent.Value2 = "emp1-value2"; + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = (Employee)s.Merge(emp); + t.Commit(); + s.Close(); + } + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = (Employee)s.Get(typeof(Employee), emp.Id); + NHibernateUtil.Initialize(emp.DirectReports); + t.Commit(); + s.Close(); + } + + Assert.That(emp.DirectReports.Count, Is.EqualTo(1)); + + enumerator = emp.DirectReports.GetEnumerator(); + enumerator.MoveNext(); + emp1 = (Employee)enumerator.Current; + Assert.That(emp1.OptionalComponent.Value1, Is.EqualTo("emp1-value1")); + Assert.That(emp1.OptionalComponent.Value2, Is.EqualTo("emp1-value2")); + + emp1.OptionalComponent.Value1 = null; + emp1.OptionalComponent.Value2 = null; + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = (Employee)s.Merge(emp); + t.Commit(); + s.Close(); + } + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + emp = (Employee)s.Get(typeof(Employee), emp.Id); + NHibernateUtil.Initialize(emp.DirectReports); + t.Commit(); + s.Close(); + } + + Assert.That(emp.DirectReports.Count, Is.EqualTo(1)); + + enumerator = emp.DirectReports.GetEnumerator(); + enumerator.MoveNext(); + emp1 = (Employee)enumerator.Current; + Assert.That(emp1.OptionalComponent, Is.Null); + + using (ISession s = sessions.OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Delete( emp ); + t.Commit(); + s.Close(); + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Component/Basic/Employee.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Component/Basic/Employee.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Component/Basic/Employee.cs 2010-07-18 15:05:47 UTC (rev 5008) @@ -0,0 +1,18 @@ +using System; +using Iesi.Collections.Generic; + +namespace NHibernate.Test.Component.Basic +{ + public class Employee + { + public virtual long Id { get; set; } + + public virtual Person Person { get; set; } + + public virtual DateTime HireDate { get; set; } + + public virtual OptionalComponent OptionalComponent { get; set; } + + public virtual ISet<Employee> DirectReports { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Component/Basic/OptionalComponent.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Component/Basic/OptionalComponent.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Component/Basic/OptionalComponent.cs 2010-07-18 15:05:47 UTC (rev 5008) @@ -0,0 +1,8 @@ +namespace NHibernate.Test.Component.Basic +{ + public class OptionalComponent + { + public string Value1 { get; set; } + public string Value2 { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Component/Basic/Person.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Component/Basic/Person.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Component/Basic/Person.cs 2010-07-18 15:05:47 UTC (rev 5008) @@ -0,0 +1,75 @@ +using System; + +namespace NHibernate.Test.Component.Basic +{ + public class Person + { + private string name; + private DateTime dob; + private string address; + private string currentAddress; + private string previousAddress; + private int yob; + private double heightInches; + + public virtual string Name + { + get { return name; } + set { name = value; } + } + + public virtual DateTime Dob + { + get { return dob; } + set { dob = value; } + } + + public virtual string Address + { + get { return address; } + set { address = value; } + } + + public virtual string CurrentAddress + { + get { return currentAddress; } + set { currentAddress = value; } + } + + public virtual string PreviousAddress + { + get { return previousAddress; } + set { previousAddress = value; } + } + + public virtual int Yob + { + get { return yob; } + set { yob = value; } + } + + public virtual double HeightInches + { + get { return heightInches; } + set { heightInches = value; } + } + + public Person() + { + } + + public Person(String name, DateTime dob, String address) + { + this.name = name; + this.dob = dob; + this.address = address; + this.currentAddress = address; + } + + public virtual void ChangeAddress(String add) + { + this.PreviousAddress = this.Address; + this.Address = add; + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Component/Basic/User.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Component/Basic/User.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Component/Basic/User.cs 2010-07-18 15:05:47 UTC (rev 5008) @@ -0,0 +1,47 @@ +using System; + +namespace NHibernate.Test.Component.Basic +{ + public class User + { + private string userName; + private string password; + private Person person; + private DateTime lastModified; + + public virtual string UserName + { + get { return userName; } + set { userName = value; } + } + + public virtual string Password + { + get { return password; } + set { password = value; } + } + + public virtual Person Person + { + get { return person; } + set { person = value; } + } + + public virtual DateTime LastModified + { + get { return lastModified; } + set { lastModified = value; } + } + + public User() + { + } + + public User(string id, string pw, Person person) + { + this.userName = id; + this.password = pw; + this.person = person; + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Component/Basic/User.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Component/Basic/User.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Component/Basic/User.hbm.xml 2010-07-18 15:05:47 UTC (rev 5008) @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping + xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.Component.Basic"> + + <class name="User" table="T_USER"> + <id name="UserName"/> + <timestamp name="LastModified"/> + <property name="Password" not-null="true" optimistic-lock="false"/> + <component name="Person"> + <property name="Name" update="false" not-null="true"/> + <property name="Dob" update="false" not-null="true"/> + <property name="Address"/> + <property name="PreviousAddress" insert="false"/> + <property name="Yob" formula="year(dob)"/> +<!-- + <property name="heightInches"> + <column name="height_centimeters" + not-null="true" + read="height_centimeters / 2.54" + write="? * 2.54"/> + </property> +--> + <property name="CurrentAddress" + column="address" + insert="false" + update="false"/> + </component> + </class> + + <class name="Employee" table="T_EMP"> + <id name="Id" type="long" column="ID"> + <generator class="increment"/> + </id> + <property name="HireDate" type="date" column="HIRE_DATE"/> + <component name="Person"> + <property name="Name" update="false" not-null="true"/> + <property name="Dob" update="false" not-null="true"/> + </component> + <component name="OptionalComponent"> + <property name="Value1" not-null="false"/> + <property name="Value2" not-null="false"/> + </component> + <set name="DirectReports" cascade="all-delete-orphan,merge" lazy="true"> + <key column="PARENT_ID" /> + <one-to-many class="Employee"/> + </set> + </class> + + <query name="userNameIn"><![CDATA[from User where Person.Name in (:nameList) or UserName in (:nameList)]]></query> + +</hibernate-mapping> \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/ExpressionTest/QueryByExampleTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/ExpressionTest/QueryByExampleTest.cs 2010-07-15 16:20:51 UTC (rev 5007) +++ trunk/nhibernate/src/NHibernate.Test/ExpressionTest/QueryByExampleTest.cs 2010-07-18 15:05:47 UTC (rev 5008) @@ -1,7 +1,7 @@ using System; using System.Collections; +using NHibernate.Criterion; using NHibernate.DomainModel; -using NHibernate.Criterion; using NUnit.Framework; namespace NHibernate.Test.ExpressionTest @@ -174,7 +174,7 @@ Componentizable master = new Componentizable(); if (name != null) { - Component masterComp = new Component(); + NHibernate.DomainModel.Component masterComp = new NHibernate.DomainModel.Component(); masterComp.Name = name; if (subName != null || subName1 != null) { Modified: trunk/nhibernate/src/NHibernate.Test/Legacy/SQLLoaderTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Legacy/SQLLoaderTest.cs 2010-07-15 16:20:51 UTC (rev 5007) +++ trunk/nhibernate/src/NHibernate.Test/Legacy/SQLLoaderTest.cs 2010-07-18 15:05:47 UTC (rev 5008) @@ -457,7 +457,7 @@ Componentizable c = new Componentizable(); c.NickName = "Flacky"; - Component component = new Component(); + NHibernate.DomainModel.Component component = new NHibernate.DomainModel.Component(); component.Name = "flakky comp"; SubComponent subComponent = new SubComponent(); subComponent.SubName = "subway"; Modified: trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs 2010-07-15 16:20:51 UTC (rev 5007) +++ trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs 2010-07-18 15:05:47 UTC (rev 5008) @@ -71,7 +71,7 @@ Assert.That(compimplements, Is.Not.Null); Assert.That(compimplements.Value, Is.EqualTo("AnotherInterface")); - Property xp = ((Component)prop.Value).GetProperty("X"); + Property xp = ((NHibernate.Mapping.Component)prop.Value).GetProperty("X"); MetaAttribute propximplements = xp.GetMetaAttribute("implements"); Assert.That(propximplements, Is.Not.Null); Assert.That(propximplements.Value, Is.EqualTo("AnotherInterface")); @@ -97,7 +97,7 @@ assertEquals( "wicked level", propertyAttribute.getValues().get(1) );*/ Assert.That(propertyAttribute.Value, Is.EqualTo("monetaryamount level")); - var component = (Component)property.Value; + var component = (NHibernate.Mapping.Component)property.Value; property = component.GetProperty("X"); propertyAttribute = property.GetMetaAttribute("globalmutated"); @@ -126,7 +126,7 @@ Assert.That(propertyAttribute.Value, Is.EqualTo("wicked level")); var bag = (Bag)property.Value; - component = (Component)bag.Element; + component = (NHibernate.Mapping.Component)bag.Element; Assert.That(component.MetaAttributes.Count, Is.EqualTo(4)); Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs 2010-07-18 15:05:47 UTC (rev 5008) @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH2061 +{ + [TestFixture] + public class Fixture : BugTestCase + { + [Test] + public void merge_with_many_to_many_inside_component_that_is_null() + { + // Order with null GroupComponent + Order newOrder = new Order(); + newOrder.GroupComponent = null; + + Order mergedCopy = null; + + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + mergedCopy = (Order)session.Merge(newOrder); + tx.Commit(); + } + + Assert.That(mergedCopy, Is.Not.Null); + Assert.That(mergedCopy.GroupComponent, Is.Null); + } + + protected override void OnTearDown() + { + using (ISession session = OpenSession()) + using (ITransaction tx = session.BeginTransaction()) + { + session.Delete("from Order"); + session.Delete("from Country"); + tx.Commit(); + } + + base.OnTearDown(); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Mappings.hbm.xml 2010-07-18 15:05:47 UTC (rev 5008) @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH2061"> + + <class name="Order" table="Orders"> + <id name="Id" unsaved-value="00000000-0000-0000-0000-000000000000"> + <generator class="guid.comb"/> + </id> + <component name="GroupComponent"> + <bag name="Countries" table="OrderCountries" cascade="none" > + <key column="OrderId" /> + <many-to-many column="CountryCode" class="Country" /> + </bag> + </component> + </class> + + <class name="Country" table="Countries"> + <id name="CountryCode"> + <generator class="assigned"/> + </id> + </class> + +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Model.cs 2010-07-18 15:05:47 UTC (rev 5008) @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH2061 +{ + public class Order + { + public virtual Guid Id { get; set; } + public virtual GroupComponent GroupComponent { get; set; } + } + + public class GroupComponent + { + public virtual IList<Country> Countries { get; set; } + } + + public class Country + { + public virtual string CountryCode { get; set; } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-15 16:20:51 UTC (rev 5007) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-18 15:05:47 UTC (rev 5008) @@ -132,6 +132,11 @@ <Compile Include="CollectionTest\IdBagFixture.cs" /> <Compile Include="CollectionTest\NullableValueTypeElementMapFixture.cs" /> <Compile Include="CollectionTest\Parent.cs" /> + <Compile Include="Component\Basic\ComponentTest.cs" /> + <Compile Include="Component\Basic\Employee.cs" /> + <Compile Include="Component\Basic\OptionalComponent.cs" /> + <Compile Include="Component\Basic\Person.cs" /> + <Compile Include="Component\Basic\User.cs" /> <Compile Include="CompositeCollection\BaseClassA.cs" /> <Compile Include="CompositeCollection\BaseClassB.cs" /> <Compile Include="CompositeCollection\ChildClassA.cs" /> @@ -443,6 +448,8 @@ <Compile Include="NHSpecificTest\CriteriaQueryOnComponentCollection\Employee.cs" /> <Compile Include="NHSpecificTest\CriteriaQueryOnComponentCollection\Fixture.cs" /> <Compile Include="NHSpecificTest\CriteriaQueryOnComponentCollection\Money.cs" /> + <Compile Include="NHSpecificTest\NH2061\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH2061\Model.cs" /> <Compile Include="NHSpecificTest\NH2069\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2069\ITest.cs" /> <Compile Include="NHSpecificTest\NH2069\ITest2.cs" /> @@ -1591,6 +1598,8 @@ <Compile Include="VersionTest\Task.cs" /> <Compile Include="VersionTest\Thing.cs" /> <Compile Include="VersionTest\VersionFixture.cs" /> + <None Include="Component\Basic\User.hbm.xml" /> + <None Include="NHSpecificTest\NH2061\Mappings.hbm.xml" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="CompositeCollection\BaseClassA.hbm.xml" /> @@ -1670,6 +1679,9 @@ <Project>{5909BFE7-93CF-4E5F-BE22-6293368AF01D}</Project> <Name>NHibernate</Name> </ProjectReference> + <Folder Include="Component" /> + <Folder Include="Component\Basic" /> + <Folder Include="NHSpecificTest\NH2061" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="NHSpecificTest\NH386\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-07-19 14:31:32
|
Revision: 5010 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5010&view=rev Author: fabiomaulo Date: 2010-07-19 14:31:25 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Marked tests as Ignore Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs Modified: trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs 2010-07-19 14:22:36 UTC (rev 5009) +++ trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs 2010-07-19 14:31:25 UTC (rev 5010) @@ -8,7 +8,7 @@ namespace NHibernate.Test.Component.Basic { - [TestFixture] + [TestFixture, Ignore("Not fixed yet.")] public class ComponentTest : TestCase { protected override string MappingsAssembly Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs 2010-07-19 14:22:36 UTC (rev 5009) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs 2010-07-19 14:31:25 UTC (rev 5010) @@ -4,7 +4,7 @@ namespace NHibernate.Test.NHSpecificTest.NH2061 { - [TestFixture] + [TestFixture, Ignore("Not fixed yet.")] public class Fixture : BugTestCase { [Test] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-07-19 14:32:22
|
Revision: 5011 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5011&view=rev Author: fabiomaulo Date: 2010-07-19 14:32:15 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Not fixed yet test for NH-2102 Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Model.cs Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Fixture.cs 2010-07-19 14:32:15 UTC (rev 5011) @@ -0,0 +1,52 @@ +using NHibernate.ByteCode.Castle; +using NHibernate.Cfg; +using NUnit.Framework; +using SharpTestsEx; + +namespace NHibernate.Test.NHSpecificTest.NH2102 +{ + [TestFixture, Ignore("Not fixed yet.")] + public class Fixture : BugTestCase + { + protected override void Configure(Configuration configuration) + { + configuration.SetProperty(Environment.ProxyFactoryFactoryClass, + typeof(ProxyFactoryFactory).AssemblyQualifiedName); + } + + [Test] + public void EntityWithConstrainedLazyLoadedOneToOneShouldNotGenerateFieldInterceptingProxy() + { + try + { + using (var s = OpenSession()) + { + var person = new Person { Id = 1, Name = "Person1" }; + var employee = new Employee { Id = 1, Name = "Emp1", Person = person }; + + s.Save(person); + s.Save(employee); + + s.Flush(); + } + + using (var s = OpenSession()) + { + var employee = s.Get<Employee>(1); + + employee.Should().Be.OfType<Employee>(); + } + } + finally + { + using (var s = OpenSession()) + { + s.Delete("from Employee"); + s.Delete("from Person"); + + s.Flush(); + } + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Mappings.hbm.xml 2010-07-19 14:32:15 UTC (rev 5011) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH2102"> + + <class name="Person"> + <id name="Id"/> + <property name="Name"></property> + </class> + + <class name="Employee"> + <id name="Id"/> + <property name="Name"></property> + + <one-to-one name="Person" constrained="true" lazy="proxy"/> + </class> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2102/Model.cs 2010-07-19 14:32:15 UTC (rev 5011) @@ -0,0 +1,16 @@ +namespace NHibernate.Test.NHSpecificTest.NH2102 +{ + public class Person + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + } + + public class Employee + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + + public virtual Person Person { get; set; } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-19 14:31:25 UTC (rev 5010) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-19 14:32:15 UTC (rev 5011) @@ -457,6 +457,8 @@ <Compile Include="NHSpecificTest\NH2069\Test.cs" /> <Compile Include="NHSpecificTest\NH2069\Test2.cs" /> <Compile Include="NHSpecificTest\NH2069\TestBase.cs" /> + <Compile Include="NHSpecificTest\NH2102\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH2102\Model.cs" /> <Compile Include="NHSpecificTest\NH2189\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2189\Model.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\AbstractIntEnumsBagFixture.cs" /> @@ -2174,6 +2176,7 @@ <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <EmbeddedResource Include="CollectionTest\NullableValueTypeElementMapFixture.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH2102\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2069\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2230\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2189\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jul...@us...> - 2010-07-19 15:31:24
|
Revision: 5014 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5014&view=rev Author: julian-maughan Date: 2010-07-19 15:31:18 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Mapping files for NH-2102 added to NHibernate.Test project as embedded resources. Tests should now pass - Ignore attributes removed. Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Modified: trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs 2010-07-19 14:59:28 UTC (rev 5013) +++ trunk/nhibernate/src/NHibernate.Test/Component/Basic/ComponentTest.cs 2010-07-19 15:31:18 UTC (rev 5014) @@ -8,7 +8,7 @@ namespace NHibernate.Test.Component.Basic { - [TestFixture, Ignore("Not fixed yet.")] + [TestFixture] public class ComponentTest : TestCase { protected override string MappingsAssembly Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs 2010-07-19 14:59:28 UTC (rev 5013) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2061/Fixture.cs 2010-07-19 15:31:18 UTC (rev 5014) @@ -4,7 +4,7 @@ namespace NHibernate.Test.NHSpecificTest.NH2061 { - [TestFixture, Ignore("Not fixed yet.")] + [TestFixture] public class Fixture : BugTestCase { [Test] Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-19 14:59:28 UTC (rev 5013) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-19 15:31:18 UTC (rev 5014) @@ -1602,8 +1602,8 @@ <Compile Include="VersionTest\Task.cs" /> <Compile Include="VersionTest\Thing.cs" /> <Compile Include="VersionTest\VersionFixture.cs" /> - <None Include="Component\Basic\User.hbm.xml" /> - <None Include="NHSpecificTest\NH2061\Mappings.hbm.xml" /> + <EmbeddedResource Include="Component\Basic\User.hbm.xml" /> + <EmbeddedResource Include="NHSpecificTest\NH2061\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2195\Mappings.hbm.xml" /> </ItemGroup> <ItemGroup> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-07-20 17:52:39
|
Revision: 5021 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5021&view=rev Author: fabiomaulo Date: 2010-07-20 17:52:31 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Passing test of NH-2092 (probably fixed by the fix of NH-2102) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Model.cs Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Fixture.cs 2010-07-20 17:52:31 UTC (rev 5021) @@ -0,0 +1,55 @@ +using NHibernate.ByteCode.Castle; +using NHibernate.Cfg; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH2092 +{ + [TestFixture] + public class Fixture : BugTestCase + { + protected override void Configure(Configuration configuration) + { + configuration.SetProperty(Environment.ProxyFactoryFactoryClass, + typeof(ProxyFactoryFactory).AssemblyQualifiedName); + } + + [Test] + public void ConstrainedLazyLoadedOneToOneUsingCastleProxy() + { + try + { + using (var s = OpenSession()) + { + var person = new Person { Id = 1, Name = "Person1" }; + var employee = new Employee { Id = 1, Name = "Emp1", Person = person }; + + s.Save(person); + s.Save(employee); + + s.Flush(); + } + + using (var s = OpenSession()) + { + var employee = s.Get<Employee>(1); + + Assert.False(NHibernateUtil.IsInitialized(employee.Person)); + + Assert.AreEqual(employee.Person.Name, "Person1"); + + Assert.True(NHibernateUtil.IsInitialized(employee.Person)); + } + } + finally + { + using (var s = OpenSession()) + { + s.Delete("from Employee"); + s.Delete("from Person"); + + s.Flush(); + } + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Mappings.hbm.xml 2010-07-20 17:52:31 UTC (rev 5021) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH2092"> + + <class name="Person"> + <id name="Id"/> + <property name="Name"></property> + </class> + + <class name="Employee"> + <id name="Id"/> + <property name="Name"></property> + + <one-to-one name="Person" constrained="true" lazy="proxy"/> + </class> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Model.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2092/Model.cs 2010-07-20 17:52:31 UTC (rev 5021) @@ -0,0 +1,16 @@ +namespace NHibernate.Test.NHSpecificTest.NH2092 +{ + public class Person + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + } + + public class Employee + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + + public virtual Person Person { get; set; } + } +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-20 17:45:07 UTC (rev 5020) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-20 17:52:31 UTC (rev 5021) @@ -457,6 +457,8 @@ <Compile Include="NHSpecificTest\NH2069\Test.cs" /> <Compile Include="NHSpecificTest\NH2069\Test2.cs" /> <Compile Include="NHSpecificTest\NH2069\TestBase.cs" /> + <Compile Include="NHSpecificTest\NH2092\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH2092\Model.cs" /> <Compile Include="NHSpecificTest\NH2093\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2093\Model.cs" /> <Compile Include="NHSpecificTest\NH2102\Fixture.cs" /> @@ -2183,6 +2185,7 @@ <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <EmbeddedResource Include="CollectionTest\NullableValueTypeElementMapFixture.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH2092\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2093\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2102\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2069\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-07-20 21:23:38
|
Revision: 5026 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5026&view=rev Author: fabiomaulo Date: 2010-07-20 21:23:32 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Test for NH-2234 Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/MyType.cs Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/Fixture.cs 2010-07-20 21:23:32 UTC (rev 5026) @@ -0,0 +1,29 @@ +using System.Linq; +using NHibernate.Linq; +using NUnit.Framework; +using SharpTestsEx; + +namespace NHibernate.Test.NHSpecificTest.NH2234 +{ + public class SomethingLinq + { + public virtual string Name { get; set; } + public virtual MyUsertype Relation { get; set; } + } + + [TestFixture, Ignore("Not fixed yet.")] + public class Fixture: BugTestCase + { + [Test] + public void CanQueryViaLinq() + { + using (var s = OpenSession()) + { + var qry = from item in s.Query<SomethingLinq>() where item.Relation == MyUserTypes.Value1 select item; + + qry.ToList(); + qry.Executing(q => q.ToList()).NotThrows(); + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/Mappings.hbm.xml 2010-07-20 21:23:32 UTC (rev 5026) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH2234"> + + <class name="SomethingLinq"> + <id type="int"> + <generator class="hilo"/> + </id> + <property name="Name"/> + <property name="Relation" type="NHibernate.Test.NHSpecificTest.NH2234.SimpleCustomType, NHibernate.Test"/> + </class> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/MyType.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/MyType.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2234/MyType.cs 2010-07-20 21:23:32 UTC (rev 5026) @@ -0,0 +1,132 @@ +using System.Collections.Generic; +using System.Data; +using NHibernate.SqlTypes; +using NHibernate.UserTypes; + +namespace NHibernate.Test.NHSpecificTest.NH2234 +{ + public class MyUsertype + { + public MyUsertype(int id, string value) + { + Id = id; + Value = value; + } + + public int Id { get; set; } + public string Value { get; set; } + + public override int GetHashCode() + { + return Id.GetHashCode(); + } + + public override bool Equals(object obj) + { + var mut = obj as MyUsertype; + return mut != null && mut.Id == Id; + } + + public static bool operator ==(MyUsertype left, MyUsertype right) + { + return Equals(left, right); + } + + public static bool operator !=(MyUsertype left, MyUsertype right) + { + return !Equals(left, right); + } + } + + public static class MyUserTypes + { + public static readonly List<MyUsertype> _values = new List<MyUsertype>() + {new MyUsertype(1, "Value 1"), new MyUsertype(2, "Value 2")}; + + + public static MyUsertype Value1 + { + get { return _values[0]; } + } + + public static MyUsertype Value2 + { + get { return _values[1]; } + } + + public static MyUsertype Find(int id) + { + return _values.Find(item => item.Id == id); + } + } + + public class SimpleCustomType : IUserType + { + private static readonly SqlType[] ReturnSqlTypes = { SqlTypeFactory.Int32 }; + + + #region IUserType Members + + public new bool Equals(object x, object y) + { + return x.Equals(y); + } + + public int GetHashCode(object x) + { + return (x == null) ? 0 : x.GetHashCode(); + } + + public SqlType[] SqlTypes + { + get { return ReturnSqlTypes; } + } + + public object DeepCopy(object value) + { + return value; + } + + public void NullSafeSet(IDbCommand cmd, object value, int index) + { + if (value == null) + NHibernateUtil.Int32.NullSafeSet(cmd, null, index, null); + else + NHibernateUtil.Int32.NullSafeSet(cmd, ((MyUsertype)value).Id, index, null); + } + + public System.Type ReturnedType + { + get { return typeof(MyUsertype); } + } + + public object NullSafeGet(IDataReader rs, string[] names, object owner) + { + int value = (int)NHibernateUtil.Int32.NullSafeGet(rs, names[0], null, owner); + return MyUserTypes.Find(value); + } + + public bool IsMutable + { + get { return false; } + } + + public object Replace(object original, object target, object owner) + { + return original; + } + + public object Assemble(object cached, object owner) + { + return cached; + } + + public object Disassemble(object value) + { + return value; + } + + #endregion + } + +} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-20 19:42:09 UTC (rev 5025) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-20 21:23:32 UTC (rev 5026) @@ -750,6 +750,8 @@ <Compile Include="NHSpecificTest\NH2201\Model.cs" /> <Compile Include="NHSpecificTest\NH2230\Domain.cs" /> <Compile Include="NHSpecificTest\NH2230\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH2234\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH2234\MyType.cs" /> <Compile Include="NHSpecificTest\NH473\Child.cs" /> <Compile Include="NHSpecificTest\NH473\Fixture.cs" /> <Compile Include="NHSpecificTest\NH473\Parent.cs" /> @@ -2187,6 +2189,7 @@ <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <EmbeddedResource Include="CollectionTest\NullableValueTypeElementMapFixture.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH2234\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2094\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2092\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2093\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2010-07-21 20:31:47
|
Revision: 5033 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5033&view=rev Author: fabiomaulo Date: 2010-07-21 20:31:40 +0000 (Wed, 21 Jul 2010) Log Message: ----------- Demonstration of ExternalIssue for NH-2207 Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2207/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2207/DomainClass.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2207/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2207/SampleTest.cs Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2207/DomainClass.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2207/DomainClass.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2207/DomainClass.cs 2010-07-21 20:31:40 UTC (rev 5033) @@ -0,0 +1,10 @@ +using System; + +namespace NHibernate.Test.NHSpecificTest.NH2207 +{ + public class DomainClass + { + public virtual int Id { get; set; } + public virtual DateTime Date { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2207/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2207/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2207/Mappings.hbm.xml 2010-07-21 20:31:40 UTC (rev 5033) @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8" ?> + <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH2207"> + <class name="DomainClass"> + <id name="Id"> + <generator class="identity" /> + </id> + <property name="Date" type="Date" not-null="true" /> + </class> +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2207/SampleTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2207/SampleTest.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2207/SampleTest.cs 2010-07-21 20:31:40 UTC (rev 5033) @@ -0,0 +1,89 @@ +using System; +using System.Data; +using NHibernate.Dialect; +using NUnit.Framework; +using SharpTestsEx; + +namespace NHibernate.Test.NHSpecificTest.NH2207 +{ + [TestFixture, Ignore("Demostration of external issue")] + public class SampleTest : BugTestCase + { + protected override bool AppliesTo(Dialect.Dialect dialect) + { + return dialect as MsSql2008Dialect != null; + } + + [Test] + public void WithoutUseNHSqlDataProviderWorkProperly() + { + var createTable = "CREATE TABLE TryDate([Id] [int] IDENTITY(1,1) NOT NULL,[MyDate] [date] NOT NULL)"; + var dropTable = "DROP TABLE TryDate"; + var insertTable = "INSERT INTO TryDate([MyDate]) VALUES(@p0)"; + using(var sqlConnection = new System.Data.SqlClient.SqlConnection(cfg.Properties[Cfg.Environment.ConnectionString])) + { + sqlConnection.Open(); + using (var tx = sqlConnection.BeginTransaction()) + { + var command = sqlConnection.CreateCommand(); + command.Transaction = tx; + command.CommandText = createTable; + command.ExecuteNonQuery(); + tx.Commit(); + } + + try + { + using (var tx = sqlConnection.BeginTransaction()) + { + var command = sqlConnection.CreateCommand(); + command.Transaction = tx; + command.CommandText = insertTable; + var dateParam = command.CreateParameter(); + dateParam.ParameterName = "@p0"; + dateParam.DbType = DbType.Date; + dateParam.Value = DateTime.MinValue.Date; + command.Parameters.Add(dateParam); + command.ExecuteNonQuery(); + tx.Commit(); + } + } + finally + { + using (var tx = sqlConnection.BeginTransaction()) + { + var command = sqlConnection.CreateCommand(); + command.Transaction = tx; + command.CommandText = dropTable; + command.ExecuteNonQuery(); + tx.Commit(); + } + } + } + + } + + [Test] + public void Dates_Before_1753_Should_Not_Insert_Null() + { + object savedId; + var expectedStoredValue = DateTime.MinValue.Date.AddDays(1).Date; + using (ISession session = OpenSession()) + using (var tx = session.BeginTransaction()) + { + var concrete = new DomainClass{Date = expectedStoredValue.AddMinutes(90)}; + savedId = session.Save(concrete); + tx.Commit(); + } + + using (ISession session = OpenSession()) + using (var tx = session.BeginTransaction()) + { + var savedObj = session.Get<DomainClass>(savedId); + savedObj.Date.Should().Be(expectedStoredValue); + session.Delete(savedObj); + tx.Commit(); + } + } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-21 17:51:11 UTC (rev 5032) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2010-07-21 20:31:40 UTC (rev 5033) @@ -752,6 +752,8 @@ <Compile Include="NHSpecificTest\NH2195\SQLiteMultiCriteriaTest.cs" /> <Compile Include="NHSpecificTest\NH2201\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2201\Model.cs" /> + <Compile Include="NHSpecificTest\NH2207\DomainClass.cs" /> + <Compile Include="NHSpecificTest\NH2207\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH2230\Domain.cs" /> <Compile Include="NHSpecificTest\NH2230\Fixture.cs" /> <Compile Include="NHSpecificTest\NH2234\Fixture.cs" /> @@ -2198,6 +2200,7 @@ <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <EmbeddedResource Include="CollectionTest\NullableValueTypeElementMapFixture.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH2207\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2243\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1891\FormulaEscaping.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH2242\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |