Skip to content

Commit ceedcd9

Browse files
committed
NH-2167 - Add failing test
1 parent 38c82fd commit ceedcd9

File tree

3 files changed

+81
-1
lines changed

3 files changed

+81
-1
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System;
2+
3+
namespace NHibernate.Test.NHSpecificTest.NH2167
4+
{
5+
class Entity
6+
{
7+
public virtual Guid Id { get; set; }
8+
public virtual string Name { get; set; }
9+
}
10+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using NHibernate.Cfg.MappingSchema;
2+
using NHibernate.Criterion;
3+
using NHibernate.Mapping.ByCode;
4+
using NUnit.Framework;
5+
6+
namespace NHibernate.Test.NHSpecificTest.NH2167
7+
{
8+
public class Fixture : TestCaseMappingByCode
9+
{
10+
protected override HbmMapping GetMappings()
11+
{
12+
var mapper = new ModelMapper();
13+
mapper.Class<Entity>(rc =>
14+
{
15+
rc.Id(x => x.Id, m => m.Generator(Generators.GuidComb));
16+
rc.Property(x => x.Name);
17+
});
18+
19+
return mapper.CompileMappingForAllExplicitlyAddedEntities();
20+
}
21+
22+
protected override void OnSetUp()
23+
{
24+
using (var session = OpenSession())
25+
using (var transaction = session.BeginTransaction())
26+
{
27+
var e1 = new Entity { Name = "Bob" };
28+
session.Save(e1);
29+
30+
var e2 = new Entity { Name = "Sally" };
31+
session.Save(e2);
32+
33+
session.Flush();
34+
transaction.Commit();
35+
}
36+
}
37+
38+
protected override void OnTearDown()
39+
{
40+
using (var session = OpenSession())
41+
using (var transaction = session.BeginTransaction())
42+
{
43+
session.Delete("from System.Object");
44+
45+
session.Flush();
46+
transaction.Commit();
47+
}
48+
}
49+
50+
[Test]
51+
public void GroupPropertyWithSqlFunctionDoesNotThrow()
52+
{
53+
using (var session = OpenSession())
54+
using (session.BeginTransaction())
55+
{
56+
var projection = session.CreateCriteria<Entity>().SetProjection(
57+
Projections.GroupProperty(
58+
Projections.SqlFunction(
59+
"substring",
60+
NHibernateUtil.String,
61+
Projections.Property("Name"),
62+
Projections.Constant(0),
63+
Projections.Constant(1))));
64+
65+
projection.List();
66+
}
67+
}
68+
}
69+
}

src/NHibernate.Test/NHibernate.Test.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,8 @@
721721
<Compile Include="NHSpecificTest\NH3609\MappingEntity.cs" />
722722
<Compile Include="NHSpecificTest\NH3609\Entity.cs" />
723723
<Compile Include="NHSpecificTest\NH3609\Fixture.cs" />
724+
<Compile Include="NHSpecificTest\NH2167\Entity.cs" />
725+
<Compile Include="NHSpecificTest\NH2167\Fixture.cs" />
724726
<Compile Include="NHSpecificTest\NH2839\FixtureByCode.cs" />
725727
<Compile Include="NHSpecificTest\NH3564\FixtureByCode.cs" />
726728
<Compile Include="NHSpecificTest\NH3583\Entity.cs" />
@@ -3722,7 +3724,6 @@
37223724
</ItemGroup>
37233725
<ItemGroup>
37243726
<Folder Include="Cascade\OneToOneCascadeDelete\Pk\Unidirectional\Hbm\" />
3725-
<Folder Include="NHSpecificTest\NH3615\" />
37263727
<Folder Include="Properties\" />
37273728
</ItemGroup>
37283729
<ItemGroup>

0 commit comments

Comments
 (0)