Skip to content

Commit 986fa50

Browse files
committed
Fix long table name and formatting
1 parent baf1031 commit 986fa50

File tree

2 files changed

+47
-61
lines changed

2 files changed

+47
-61
lines changed

src/NHibernate.Test/Async/NHSpecificTest/GH2043/Fixture.cs

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
using System;
1212
using System.Linq;
13-
using NHibernate.Cfg;
1413
using NHibernate.Cfg.MappingSchema;
1514
using NHibernate.Mapping.ByCode;
1615
using NUnit.Framework;
@@ -22,9 +21,7 @@ namespace NHibernate.Test.NHSpecificTest.GH2043
2221
[TestFixture]
2322
public class FixtureAsync : TestCaseMappingByCode
2423
{
25-
private Guid _entityWithClassProxy1Id;
2624
private Guid _entityWithClassProxy2Id;
27-
private Guid _entityWithInterfaceProxy1Id;
2825
private Guid _entityWithInterfaceProxy2Id;
2926
private Guid _entityWithClassLookupId;
3027
private Guid _entityWithInterfaceLookupId;
@@ -34,6 +31,7 @@ protected override HbmMapping GetMappings()
3431
var mapper = new ModelMapper();
3532
mapper.Class<EntityWithClassProxyDefinition>(rc =>
3633
{
34+
rc.Table("ProxyDefinition");
3735
rc.Proxy(typeof(EntityWithClassProxyDefinition));
3836

3937
rc.Id(x => x.Id);
@@ -42,6 +40,7 @@ protected override HbmMapping GetMappings()
4240

4341
mapper.Class<EntityWithInterfaceProxyDefinition>(rc =>
4442
{
43+
rc.Table("IProxyDefinition");
4544
rc.Proxy(typeof(IEntityProxy));
4645

4746
rc.Id(x => x.Id);
@@ -69,13 +68,13 @@ protected override HbmMapping GetMappings()
6968
protected override void OnSetUp()
7069
{
7170
using(var session = OpenSession())
71+
using (var transaction = session.BeginTransaction())
7272
{
7373
var entityCP1 = new EntityWithClassProxyDefinition
7474
{
7575
Id = Guid.NewGuid(),
7676
Name = "Name 1"
7777
};
78-
_entityWithClassProxy1Id = entityCP1.Id;
7978

8079
var entityCP2 = new EntityWithClassProxyDefinition
8180
{
@@ -89,7 +88,6 @@ protected override void OnSetUp()
8988
Id = Guid.NewGuid(),
9089
Name = "Name 1"
9190
};
92-
_entityWithInterfaceProxy1Id = entityIP1.Id;
9391

9492
var entityIP2 = new EntityWithInterfaceProxyDefinition
9593
{
@@ -123,21 +121,20 @@ protected override void OnSetUp()
123121
session.Save(entityIL);
124122

125123
session.Flush();
124+
transaction.Commit();
126125
}
127126
}
128127

129128

130129
protected override void OnTearDown()
131130
{
132131
using (var session = OpenSession())
132+
using (var transaction = session.BeginTransaction())
133133
{
134-
using (var transaction = session.BeginTransaction())
135-
{
136-
session.Delete("from System.Object");
134+
session.Delete("from System.Object");
137135

138-
session.Flush();
139-
transaction.Commit();
140-
}
136+
session.Flush();
137+
transaction.Commit();
141138
}
142139
}
143140

@@ -146,38 +143,34 @@ protected override void OnTearDown()
146143
public async Task UpdateEntityWithClassLookupAsync()
147144
{
148145
using (var session = OpenSession())
146+
using (var transaction = session.BeginTransaction())
149147
{
150-
using(var transaction = session.BeginTransaction())
151-
{
152-
var entityToUpdate = await (session.Query<EntityWithClassLookup>()
153-
.FirstAsync(e => e.Id == _entityWithClassLookupId));
148+
var entityToUpdate = await (session.Query<EntityWithClassLookup>()
149+
.FirstAsync(e => e.Id == _entityWithClassLookupId));
154150

155-
entityToUpdate.EntityLookup = (EntityWithClassProxyDefinition)await (session.LoadAsync(typeof(EntityWithClassProxyDefinition), _entityWithClassProxy2Id));
151+
entityToUpdate.EntityLookup = (EntityWithClassProxyDefinition) await (session.LoadAsync(typeof(EntityWithClassProxyDefinition), _entityWithClassProxy2Id));
156152

157-
await (session.UpdateAsync(entityToUpdate));
158-
await (session.FlushAsync());
159-
await (transaction.RollbackAsync());
160-
}
153+
await (session.UpdateAsync(entityToUpdate));
154+
await (session.FlushAsync());
155+
await (transaction.CommitAsync());
161156
}
162157
}
163158

164159

165160
[Test]
166161
public async Task UpdateEntityWithInterfaceLookupAsync()
167162
{
168-
using(var session = OpenSession())
163+
using (var session = OpenSession())
164+
using (var transaction = session.BeginTransaction())
169165
{
170-
using(var transaction = session.BeginTransaction())
171-
{
172-
var entityToUpdate = await (session.Query<EntityWithInterfaceLookup>()
173-
.FirstAsync(e => e.Id == _entityWithInterfaceLookupId));
166+
var entityToUpdate = await (session.Query<EntityWithInterfaceLookup>()
167+
.FirstAsync(e => e.Id == _entityWithInterfaceLookupId));
174168

175-
entityToUpdate.EntityLookup = (IEntityProxy)await (session.LoadAsync(typeof(EntityWithInterfaceProxyDefinition), _entityWithInterfaceProxy2Id));
169+
entityToUpdate.EntityLookup = (IEntityProxy) await (session.LoadAsync(typeof(EntityWithInterfaceProxyDefinition), _entityWithInterfaceProxy2Id));
176170

177-
await (session.UpdateAsync(entityToUpdate));
178-
await (session.FlushAsync());
179-
await (transaction.RollbackAsync());
180-
}
171+
await (session.UpdateAsync(entityToUpdate));
172+
await (session.FlushAsync());
173+
await (transaction.CommitAsync());
181174
}
182175
}
183176
}

src/NHibernate.Test/NHSpecificTest/GH2043/Fixture.cs

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Linq;
3-
using NHibernate.Cfg;
43
using NHibernate.Cfg.MappingSchema;
54
using NHibernate.Mapping.ByCode;
65
using NUnit.Framework;
@@ -10,18 +9,17 @@ namespace NHibernate.Test.NHSpecificTest.GH2043
109
[TestFixture]
1110
public class Fixture : TestCaseMappingByCode
1211
{
13-
private Guid _entityWithClassProxy1Id;
1412
private Guid _entityWithClassProxy2Id;
15-
private Guid _entityWithInterfaceProxy1Id;
1613
private Guid _entityWithInterfaceProxy2Id;
1714
private Guid _entityWithClassLookupId;
1815
private Guid _entityWithInterfaceLookupId;
19-
16+
2017
protected override HbmMapping GetMappings()
2118
{
2219
var mapper = new ModelMapper();
2320
mapper.Class<EntityWithClassProxyDefinition>(rc =>
2421
{
22+
rc.Table("ProxyDefinition");
2523
rc.Proxy(typeof(EntityWithClassProxyDefinition));
2624

2725
rc.Id(x => x.Id);
@@ -30,6 +28,7 @@ protected override HbmMapping GetMappings()
3028

3129
mapper.Class<EntityWithInterfaceProxyDefinition>(rc =>
3230
{
31+
rc.Table("IProxyDefinition");
3332
rc.Proxy(typeof(IEntityProxy));
3433

3534
rc.Id(x => x.Id);
@@ -57,13 +56,13 @@ protected override HbmMapping GetMappings()
5756
protected override void OnSetUp()
5857
{
5958
using(var session = OpenSession())
59+
using (var transaction = session.BeginTransaction())
6060
{
6161
var entityCP1 = new EntityWithClassProxyDefinition
6262
{
6363
Id = Guid.NewGuid(),
6464
Name = "Name 1"
6565
};
66-
_entityWithClassProxy1Id = entityCP1.Id;
6766

6867
var entityCP2 = new EntityWithClassProxyDefinition
6968
{
@@ -77,7 +76,6 @@ protected override void OnSetUp()
7776
Id = Guid.NewGuid(),
7877
Name = "Name 1"
7978
};
80-
_entityWithInterfaceProxy1Id = entityIP1.Id;
8179

8280
var entityIP2 = new EntityWithInterfaceProxyDefinition
8381
{
@@ -111,21 +109,20 @@ protected override void OnSetUp()
111109
session.Save(entityIL);
112110

113111
session.Flush();
112+
transaction.Commit();
114113
}
115114
}
116115

117116

118117
protected override void OnTearDown()
119118
{
120119
using (var session = OpenSession())
120+
using (var transaction = session.BeginTransaction())
121121
{
122-
using (var transaction = session.BeginTransaction())
123-
{
124-
session.Delete("from System.Object");
122+
session.Delete("from System.Object");
125123

126-
session.Flush();
127-
transaction.Commit();
128-
}
124+
session.Flush();
125+
transaction.Commit();
129126
}
130127
}
131128

@@ -134,38 +131,34 @@ protected override void OnTearDown()
134131
public void UpdateEntityWithClassLookup()
135132
{
136133
using (var session = OpenSession())
134+
using (var transaction = session.BeginTransaction())
137135
{
138-
using(var transaction = session.BeginTransaction())
139-
{
140-
var entityToUpdate = session.Query<EntityWithClassLookup>()
141-
.First(e => e.Id == _entityWithClassLookupId);
136+
var entityToUpdate = session.Query<EntityWithClassLookup>()
137+
.First(e => e.Id == _entityWithClassLookupId);
142138

143-
entityToUpdate.EntityLookup = (EntityWithClassProxyDefinition)session.Load(typeof(EntityWithClassProxyDefinition), _entityWithClassProxy2Id);
139+
entityToUpdate.EntityLookup = (EntityWithClassProxyDefinition) session.Load(typeof(EntityWithClassProxyDefinition), _entityWithClassProxy2Id);
144140

145-
session.Update(entityToUpdate);
146-
session.Flush();
147-
transaction.Rollback();
148-
}
141+
session.Update(entityToUpdate);
142+
session.Flush();
143+
transaction.Commit();
149144
}
150145
}
151146

152147

153148
[Test]
154149
public void UpdateEntityWithInterfaceLookup()
155150
{
156-
using(var session = OpenSession())
151+
using (var session = OpenSession())
152+
using (var transaction = session.BeginTransaction())
157153
{
158-
using(var transaction = session.BeginTransaction())
159-
{
160-
var entityToUpdate = session.Query<EntityWithInterfaceLookup>()
161-
.First(e => e.Id == _entityWithInterfaceLookupId);
154+
var entityToUpdate = session.Query<EntityWithInterfaceLookup>()
155+
.First(e => e.Id == _entityWithInterfaceLookupId);
162156

163-
entityToUpdate.EntityLookup = (IEntityProxy)session.Load(typeof(EntityWithInterfaceProxyDefinition), _entityWithInterfaceProxy2Id);
157+
entityToUpdate.EntityLookup = (IEntityProxy) session.Load(typeof(EntityWithInterfaceProxyDefinition), _entityWithInterfaceProxy2Id);
164158

165-
session.Update(entityToUpdate);
166-
session.Flush();
167-
transaction.Rollback();
168-
}
159+
session.Update(entityToUpdate);
160+
session.Flush();
161+
transaction.Commit();
169162
}
170163
}
171164
}

0 commit comments

Comments
 (0)