Skip to content

Commit 3860bd7

Browse files
committed
fixup! Test the explicit interface case
1 parent 270833e commit 3860bd7

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/NHibernate.Test/StaticProxyTest/StaticProxyFactoryFixture.cs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public void VerifyProxyForClassWithInternalInterface()
158158
}
159159

160160
[Test]
161-
public void VerifyProxyOnInterface()
161+
public void VerifyProxyForClassWithAdditionalInterface()
162162
{
163163
var factory = new StaticProxyFactory();
164164
factory.PostInstantiate(
@@ -186,7 +186,7 @@ public void VerifyProxyOnInterface()
186186
}
187187

188188
[Test]
189-
public void VerifyProxyForClassWithAdditionalInterface()
189+
public void VerifyProxyForClassWithInterface()
190190
{
191191
var factory = new StaticProxyFactory();
192192
factory.PostInstantiate(
@@ -212,8 +212,8 @@ public void VerifyProxyForClassWithAdditionalInterface()
212212
var ent = (PublicInterfaceTestClass) proxy;
213213
Assert.That(pub.Id, Is.EqualTo(5), "IPublic.Id");
214214
Assert.That(ent.Id, Is.EqualTo(5), "entity.Id");
215-
Assert.That(pub.Name, Is.EqualTo("State"), "IPublic.State");
216-
Assert.That(ent.Name, Is.EqualTo("State"), "entity.State");
215+
Assert.That(pub.Name, Is.EqualTo("State"), "IPublic.Name");
216+
Assert.That(ent.Name, Is.EqualTo("State"), "entity.Name");
217217
ent.Id = 10;
218218
pub.Name = "Test";
219219
Assert.That(pub.Id, Is.EqualTo(10), "IPublic.Id");
@@ -226,7 +226,7 @@ public void VerifyProxyForClassWithAdditionalInterface()
226226
}
227227

228228
[Test]
229-
public void VerifyProxyForClassWithAdditionalExplicitInterface()
229+
public void VerifyProxyForClassWithExplicitInterface()
230230
{
231231
var factory = new StaticProxyFactory();
232232
factory.PostInstantiate(
@@ -243,6 +243,22 @@ public void VerifyProxyForClassWithAdditionalExplicitInterface()
243243
Assert.That(proxy, Is.Not.Null);
244244
Assert.That(proxy, Is.InstanceOf<IPublic>());
245245
Assert.That(proxy, Is.InstanceOf<PublicExplicitInterfaceTestClass>());
246+
247+
// Check interface and implicit implementations do both call the delegated state
248+
IPublic state = new PublicExplicitInterfaceTestClass();
249+
state.Id = 5;
250+
state.Name = "State";
251+
proxy.HibernateLazyInitializer.SetImplementation(state);
252+
var entity = (IPublic) proxy;
253+
Assert.That(entity.Id, Is.EqualTo(5), "Id");
254+
Assert.That(entity.Name, Is.EqualTo("State"), "Name");
255+
256+
entity.Id = 10;
257+
entity.Name = "Test";
258+
Assert.That(entity.Id, Is.EqualTo(10), "entity.Id");
259+
Assert.That(state.Id, Is.EqualTo(10), "state.Id");
260+
Assert.That(entity.Name, Is.EqualTo("Test"), "entity.Name");
261+
Assert.That(state.Name, Is.EqualTo("Test"), "state.Name");
246262
#if NETFX
247263
});
248264
#endif

0 commit comments

Comments
 (0)