Skip to content

Commit fadf5b6

Browse files
committed
Use simpler mapping for interface proxy test
1 parent 666494c commit fadf5b6

File tree

4 files changed

+39
-10
lines changed

4 files changed

+39
-10
lines changed

src/NHibernate.Test/Async/StaticProxyTest/InterfaceHandling/Fixture.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected override HbmMapping GetMappings()
4545
mapper.UnionSubclass<AnotherSubEntityInterfaceProxy>(
4646
rc =>
4747
{
48-
rc.Proxy(typeof(IAmbigiousSubEntityProxy));
48+
rc.Proxy(typeof(IAnotherEntityProxy));
4949

5050
rc.Property(x => x.AnotherName);
5151
});
@@ -85,6 +85,15 @@ protected override HbmMapping GetMappings()
8585
mapper.Class<EntityMixExplicitImplicitInterface>(
8686
rc =>
8787
{
88+
rc.Table("multiInterface");
89+
rc.Id(x => x.Id);
90+
rc.Property(x => x.Name);
91+
});
92+
93+
mapper.Class<EntityMultiIdProxy>(
94+
rc =>
95+
{
96+
rc.Proxy(typeof(IMultiIdProxy));
8897
rc.Id(x => x.Id);
8998
rc.Property(x => x.Name);
9099
});
@@ -145,7 +154,7 @@ public async Task ProxyClassIdAccessBothImplicitExplicitInterfacesAsync()
145154
}
146155

147156
[Test]
148-
public async Task ProxyInterfaceAsync()
157+
public async Task ProxyInterfaceIdAccessAsync()
149158
{
150159
using (var session = OpenSession())
151160
{
@@ -157,11 +166,11 @@ public async Task ProxyInterfaceAsync()
157166

158167
[KnownBug("GH-2271")]
159168
[Test]
160-
public async Task ProxyInterfaceCanAccessIdFromDifferentInterfacesAsync()
169+
public async Task ProxyInterfaceIdAccessFromDifferentInterfacesAsync()
161170
{
162171
using (var session = OpenSession())
163172
{
164-
var entity = await (session.LoadAsync<IAmbigiousSubEntityProxy>(_id));
173+
var entity = await (session.LoadAsync<IMultiIdProxy>(_id));
165174

166175
CanAccessIEntityId(entity);
167176
CanAccessIEntity2Id(entity);

src/NHibernate.Test/StaticProxyTest/InterfaceHandling/Entities.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ string IEntity.Name
3838
}
3939
}
4040

41+
//Proxy contains IEntity.Id and IEntity2.Id
42+
public interface IMultiIdProxy : IEntity, IEntity2
43+
{
44+
}
45+
46+
public class EntityMultiIdProxy : IMultiIdProxy
47+
{
48+
public virtual Guid Id { get; set; }
49+
public virtual string Name { get; set; }
50+
}
51+
4152
public class EntityMixExplicitImplicitInterface : IEntity, IEntity2
4253
{
4354
private Guid id;

src/NHibernate.Test/StaticProxyTest/InterfaceHandling/Fixture.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected override HbmMapping GetMappings()
3434
mapper.UnionSubclass<AnotherSubEntityInterfaceProxy>(
3535
rc =>
3636
{
37-
rc.Proxy(typeof(IAmbigiousSubEntityProxy));
37+
rc.Proxy(typeof(IAnotherEntityProxy));
3838

3939
rc.Property(x => x.AnotherName);
4040
});
@@ -74,6 +74,15 @@ protected override HbmMapping GetMappings()
7474
mapper.Class<EntityMixExplicitImplicitInterface>(
7575
rc =>
7676
{
77+
rc.Table("multiInterface");
78+
rc.Id(x => x.Id);
79+
rc.Property(x => x.Name);
80+
});
81+
82+
mapper.Class<EntityMultiIdProxy>(
83+
rc =>
84+
{
85+
rc.Proxy(typeof(IMultiIdProxy));
7786
rc.Id(x => x.Id);
7887
rc.Property(x => x.Name);
7988
});
@@ -134,7 +143,7 @@ public void ProxyClassIdAccessBothImplicitExplicitInterfaces()
134143
}
135144

136145
[Test]
137-
public void ProxyInterface()
146+
public void ProxyInterfaceIdAccess()
138147
{
139148
using (var session = OpenSession())
140149
{
@@ -146,11 +155,11 @@ public void ProxyInterface()
146155

147156
[KnownBug("GH-2271")]
148157
[Test]
149-
public void ProxyInterfaceCanAccessIdFromDifferentInterfaces()
158+
public void ProxyInterfaceIdAccessFromDifferentInterfaces()
150159
{
151160
using (var session = OpenSession())
152161
{
153-
var entity = session.Load<IAmbigiousSubEntityProxy>(_id);
162+
var entity = session.Load<IMultiIdProxy>(_id);
154163

155164
CanAccessIEntityId(entity);
156165
CanAccessIEntity2Id(entity);

src/NHibernate.Test/StaticProxyTest/InterfaceHandling/SubclassEntities.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ class SubEntityInterfaceProxy : EntityClassProxy, ISubEntityProxy
1919
public virtual string AnotherName { get; set; }
2020
}
2121

22-
public interface IAmbigiousSubEntityProxy : IEntity, IEntity2
22+
public interface IAnotherEntityProxy : IEntity
2323
{
2424
string AnotherName { get; set; }
2525
}
2626

27-
class AnotherSubEntityInterfaceProxy : EntityClassProxy, IAmbigiousSubEntityProxy
27+
class AnotherSubEntityInterfaceProxy : EntityClassProxy, IAnotherEntityProxy
2828
{
2929
public virtual string AnotherName { get; set; }
3030
}

0 commit comments

Comments
 (0)