Skip to content

Commit e8b9f03

Browse files
committed
Merge pull request #406 from nhibernate/NH-3589
NH-3589 - Refactor test applicable to MS SQL only
2 parents 450d14b + bfe2168 commit e8b9f03

File tree

5 files changed

+71
-66
lines changed

5 files changed

+71
-66
lines changed

src/NHibernate.Test/NHibernate.Test.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2538,8 +2538,9 @@
25382538
<Compile Include="VersionTest\Db\MsSQL\GeneratedBinaryVersionFixture.cs" />
25392539
<Compile Include="VersionTest\Db\MsSQL\SimpleVersioned.cs" />
25402540
<Compile Include="VersionTest\Db\Permission.cs" />
2541+
<Compile Include="VersionTest\Db\MsSQL\ProductWithVersionAndLazyProperty.cs" />
25412542
<Compile Include="VersionTest\Db\User.cs" />
2542-
<Compile Include="VersionTest\Db\LazyVersionTest.cs" />
2543+
<Compile Include="VersionTest\Db\MsSQL\LazyVersionTest.cs" />
25432544
<Compile Include="VersionTest\Person.cs" />
25442545
<Compile Include="VersionTest\Task.cs" />
25452546
<Compile Include="VersionTest\Thing.cs" />
@@ -3135,6 +3136,7 @@
31353136
<EmbeddedResource Include="NHSpecificTest\NH1291AnonExample\Mappings.hbm.xml" />
31363137
</ItemGroup>
31373138
<ItemGroup>
3139+
<EmbeddedResource Include="VersionTest\Db\MsSQL\ProductWithVersionAndLazyProperty.hbm.xml" />
31383140
<EmbeddedResource Include="NHSpecificTest\NH3754\Mappings.hbm.xml" />
31393141
<EmbeddedResource Include="LazyComponentTest\Person.hbm.xml" />
31403142
<EmbeddedResource Include="NHSpecificTest\NH3372\Mappings.hbm.xml" />

src/NHibernate.Test/VersionTest/Db/LazyVersionTest.cs

Lines changed: 0 additions & 65 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System.Collections;
2+
using NHibernate.Dialect;
3+
using NUnit.Framework;
4+
5+
namespace NHibernate.Test.VersionTest.Db.MsSQL
6+
{
7+
[TestFixture]
8+
public class LazyVersionTest : TestCase
9+
{
10+
protected override bool AppliesTo(Dialect.Dialect dialect)
11+
{
12+
return dialect is MsSql2000Dialect;
13+
}
14+
15+
protected override IList Mappings
16+
{
17+
get { return new[] { "VersionTest.Db.MsSQL.ProductWithVersionAndLazyProperty.hbm.xml" }; }
18+
}
19+
20+
protected override string MappingsAssembly
21+
{
22+
get { return "NHibernate.Test"; }
23+
}
24+
25+
[Test(Description = "NH-3589")]
26+
public void CanUseVersionOnEntityWithLazyProperty()
27+
{
28+
using (var session = OpenSession())
29+
using (session.BeginTransaction())
30+
{
31+
session.Save(new ProductWithVersionAndLazyProperty { Id = 1, Summary = "Testing, 1, 2, 3" });
32+
33+
session.Flush();
34+
35+
session.Clear();
36+
37+
var p = session.Get<ProductWithVersionAndLazyProperty>(1);
38+
39+
p.Summary += ", 4!";
40+
41+
session.Flush();
42+
}
43+
}
44+
}
45+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace NHibernate.Test.VersionTest.Db.MsSQL
2+
{
3+
public class ProductWithVersionAndLazyProperty
4+
{
5+
byte[] _version = null;
6+
7+
public virtual int Id { get; set; }
8+
9+
public virtual string Summary { get; set; }
10+
11+
public virtual byte[] Version { get { return _version; } }
12+
}
13+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NHibernate.Test.VersionTest.Db.MsSQL" assembly="NHibernate.Test">
3+
<class name="ProductWithVersionAndLazyProperty">
4+
<id name="Id" generator="assigned" />
5+
<version name="Version" generated="always" unsaved-value="null" type="BinaryBlob" access="nosetter.camelcase-underscore">
6+
<column name="version" not-null="false" sql-type="timestamp" />
7+
</version>
8+
<property name="Summary" lazy="true" />
9+
</class>
10+
</hibernate-mapping>

0 commit comments

Comments
 (0)