|
From: <fab...@us...> - 2011-04-07 20:44:12
|
Revision: 5633
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5633&view=rev
Author: fabiomaulo
Date: 2011-04-07 20:44:05 +0000 (Thu, 07 Apr 2011)
Log Message:
-----------
Test for NH-2632 (not fixed yet)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2632/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2632/Domain.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2632/Fixture.cs
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2632/Domain.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2632/Domain.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2632/Domain.cs 2011-04-07 20:44:05 UTC (rev 5633)
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+
+namespace NHibernate.Test.NHSpecificTest.NH2632
+{
+ public class Customer
+ {
+ public virtual Int64 Id
+ {
+ get;
+ private set;
+ }
+ public virtual String Name
+ {
+ get;
+ set;
+ }
+ public virtual String Address
+ {
+ get;
+ set;
+ }
+ public virtual IEnumerable<Order> Orders
+ {
+ get;
+ private set;
+ }
+ }
+
+ public class Order
+ {
+ public virtual Int32 Id
+ {
+ get;
+ private set;
+ }
+
+ public virtual DateTime Date
+ {
+ get;
+ set;
+ }
+
+ public virtual Customer Customer
+ {
+ get;
+ set;
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2632/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2632/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH2632/Fixture.cs 2011-04-07 20:44:05 UTC (rev 5633)
@@ -0,0 +1,103 @@
+using System;
+using NHibernate.Cfg;
+using NHibernate.Cfg.Loquacious;
+using NHibernate.Cfg.MappingSchema;
+using NHibernate.Mapping.ByCode;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.NHSpecificTest.NH2632
+{
+ public class Fixture: TestCaseMappingByCode
+ {
+ protected override HbmMapping GetMappings()
+ {
+ // The impl/mapping of the bidirectional one-to-many sucks but was provided as is
+ var mapper = new ModelMapper();
+ mapper.BeforeMapClass += (i, t, cm) => cm.Id(map =>
+ {
+ map.Column((t.Name + "Id").ToUpperInvariant());
+ map.Generator(Generators.HighLow, g => g.Params(new { max_lo = "1000" }));
+ });
+ mapper.Class<Customer>(ca =>
+ {
+ ca.Lazy(false);
+ ca.Id(x => x.Id, m => { });
+ ca.NaturalId(x => x.Property(c => c.Name, p => p.NotNullable(true)));
+ ca.Property(x => x.Address, p => p.Lazy(true));
+ ca.Set(c => c.Orders, c =>
+ {
+ c.Key(x => x.Column("CUSTOMERID"));
+ c.Inverse(true);
+ c.Cascade(Mapping.ByCode.Cascade.All);
+ }, c => c.OneToMany());
+ });
+ mapper.Class<Order>(cm =>
+ {
+ cm.Id(x => x.Id, m => { });
+ cm.Property(x => x.Date);
+ cm.ManyToOne(x => x.Customer, map => map.Column("CUSTOMERID"));
+ });
+ return mapper.CompileMappingForAllExplicitAddedEntities();
+ }
+
+ protected override void Configure(Cfg.Configuration configuration)
+ {
+ configuration.DataBaseIntegration(di => di.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote);
+ }
+
+ private class Scenario : IDisposable
+ {
+ private readonly ISessionFactory factory;
+ private object customerId;
+
+ public Scenario(ISessionFactory factory)
+ {
+ this.factory = factory;
+ using (ISession s = factory.OpenSession())
+ {
+ using (ITransaction t = s.BeginTransaction())
+ {
+ var customer = new Customer { Name="Zombi", Address = "Bah?!??"};
+ var order = new Order { Date = DateTime.Today, Customer = customer };
+ customerId = s.Save(customer);
+ s.Save(order);
+ t.Commit();
+ }
+ }
+ }
+
+ public object CustomerId
+ {
+ get { return customerId; }
+ }
+
+ public void Dispose()
+ {
+ using (ISession s = factory.OpenSession())
+ {
+ using (ITransaction t = s.BeginTransaction())
+ {
+ s.Delete("from Order");
+ s.Delete("from Customer");
+ t.Commit();
+ }
+ }
+ }
+ }
+
+ [Test, Ignore("Not fixed yet")]
+ public void GettingCustomerDoesNotThrow()
+ {
+ using (var scenario = new Scenario(Sfi))
+ {
+ using (var session = OpenSession())
+ {
+ Customer customer = null;
+ Executing.This(()=> customer = session.Get<Customer>(scenario.CustomerId)).Should().NotThrow();
+ NHibernateUtil.IsInitialized(customer.Address).Should().Be.False();
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-07 19:44:21 UTC (rev 5632)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-07 20:44:05 UTC (rev 5633)
@@ -719,6 +719,8 @@
<Compile Include="NHSpecificTest\NH2580\Fixture.cs" />
<Compile Include="NHSpecificTest\NH2603\Fixture.cs" />
<Compile Include="NHSpecificTest\NH2603\Model.cs" />
+ <Compile Include="NHSpecificTest\NH2632\Domain.cs" />
+ <Compile Include="NHSpecificTest\NH2632\Fixture.cs" />
<Compile Include="NHSpecificTest\Properties\CompositePropertyRefTest.cs" />
<Compile Include="NHSpecificTest\Properties\DynamicEntityTest.cs" />
<Compile Include="NHSpecificTest\Properties\Model.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|