Skip to content

Commit 2393685

Browse files
committed
Failing tests for issue NH-3666
1 parent bcc669e commit 2393685

File tree

4 files changed

+107
-0
lines changed

4 files changed

+107
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace NHibernate.Test.NHSpecificTest.NH3666
7+
{
8+
public class Entity
9+
{
10+
public virtual int Id { get; set; }
11+
public virtual string Property { get; set; }
12+
}
13+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
using NUnit.Framework;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
7+
namespace NHibernate.Test.NHSpecificTest.NH3666
8+
{
9+
[TestFixture]
10+
public class Fixture : BugTestCase
11+
{
12+
protected override void OnSetUp()
13+
{
14+
using (var session = this.OpenSession())
15+
using (var transaction = session.BeginTransaction())
16+
{
17+
var entity1 = new Entity { Id = 1, Property = "Test1" };
18+
var entity2 = new Entity { Id = 2, Property = "Test2" };
19+
var entity3 = new Entity { Id = 3, Property = "Test3" };
20+
21+
session.Save(entity1);
22+
session.Save(entity2);
23+
session.Save(entity3);
24+
25+
transaction.Commit();
26+
}
27+
}
28+
29+
protected override void OnTearDown()
30+
{
31+
using (var session = this.OpenSession())
32+
using (var transaction = session.BeginTransaction())
33+
{
34+
session.Delete("from Entity");
35+
transaction.Commit();
36+
}
37+
}
38+
39+
[Test]
40+
public void CacheableDoesNotThrowExceptionWithNativeSQLQuery()
41+
{
42+
using (var session = this.OpenSession())
43+
using (var transaction = session.BeginTransaction())
44+
{
45+
var result = session.CreateSQLQuery("SELECT * FROM Entity WHERE Property = 'Test2'")
46+
.AddEntity(typeof(Entity))
47+
.SetCacheable(true)
48+
.List<Entity>();
49+
50+
CollectionAssert.IsNotEmpty(result);
51+
52+
Assert.AreEqual(1, result.Count);
53+
Assert.AreEqual(2, result[0].Id);
54+
}
55+
}
56+
57+
[Test]
58+
public void CacheableDoesNotThrowExceptionWithNamedQuery()
59+
{
60+
using (var session = this.OpenSession())
61+
using (var transaction = session.BeginTransaction())
62+
{
63+
var result = session.GetNamedQuery("QueryName")
64+
.SetCacheable(true)
65+
.SetString("prop", "Test2")
66+
.List<Entity>();
67+
68+
CollectionAssert.IsNotEmpty(result);
69+
70+
Assert.AreEqual(1, result.Count);
71+
Assert.AreEqual(2, result[0].Id);
72+
}
73+
}
74+
}
75+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH3666">
3+
<class name="Entity" table="Entity">
4+
<id name="Id" access="property" column="Id" type="Int32" unsaved-value="0">
5+
<generator class="assigned" />
6+
</id>
7+
<property name="Property" type="String" />
8+
</class>
9+
10+
<sql-query name="QueryName">
11+
<return class="Entity" />
12+
SELECT * FROM Entity WHERE Property = :prop
13+
</sql-query>
14+
</hibernate-mapping>

src/NHibernate.Test/NHibernate.Test.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,8 @@
732732
<Compile Include="NHSpecificTest\NH3570\BiFixture.cs" />
733733
<Compile Include="NHSpecificTest\NH3570\Model.cs" />
734734
<Compile Include="NHSpecificTest\NH3570\UniFixture.cs" />
735+
<Compile Include="NHSpecificTest\NH3666\Entity.cs" />
736+
<Compile Include="NHSpecificTest\NH3666\Fixture.cs" />
735737
<Compile Include="NHSpecificTest\NH3731\Entity.cs" />
736738
<Compile Include="NHSpecificTest\NH3731\FixtureByCode.cs" />
737739
<Compile Include="NHSpecificTest\NH2053\Cat.cs" />
@@ -3128,6 +3130,9 @@
31283130
<EmbeddedResource Include="NHSpecificTest\NH1291AnonExample\Mappings.hbm.xml" />
31293131
</ItemGroup>
31303132
<ItemGroup>
3133+
<EmbeddedResource Include="NHSpecificTest\NH3666\Mappings.hbm.xml">
3134+
<SubType>Designer</SubType>
3135+
</EmbeddedResource>
31313136
<EmbeddedResource Include="VersionTest\Db\MsSQL\ProductWithVersionAndLazyProperty.hbm.xml" />
31323137
<EmbeddedResource Include="NHSpecificTest\NH3754\Mappings.hbm.xml" />
31333138
<EmbeddedResource Include="LazyComponentTest\Person.hbm.xml" />

0 commit comments

Comments
 (0)