1- using System ;
21using JsonApiDotNetCore . Builders ;
32using JsonApiDotNetCore . Configuration ;
43using JsonApiDotNetCore . Internal ;
54using JsonApiDotNetCore . Models ;
65using Microsoft . EntityFrameworkCore ;
76using Microsoft . Extensions . Logging ;
87using Microsoft . Extensions . Logging . Abstractions ;
8+ using Castle . DynamicProxy ;
99using Xunit ;
1010
1111namespace UnitTests . Internal
@@ -50,16 +50,18 @@ public void GetResourceContext_Yields_Right_Type_For_Proxy()
5050 var resourceGraphBuilder = new ResourceGraphBuilder ( new JsonApiOptions ( ) , NullLoggerFactory . Instance ) ;
5151 resourceGraphBuilder . AddResource < Bar > ( ) ;
5252 var resourceGraph = ( ResourceGraph ) resourceGraphBuilder . Build ( ) ;
53+ var proxyGenerator = new ProxyGenerator ( ) ;
5354
5455 // Act
55- var result = resourceGraph . GetResourceContext ( typeof ( DummyProxy ) ) ;
56+ var proxy = proxyGenerator . CreateClassProxy < Bar > ( ) ;
57+ var result = resourceGraph . GetResourceContext ( proxy . GetType ( ) ) ;
5658
5759 // Assert
5860 Assert . Equal ( typeof ( Bar ) , result . ResourceType ) ;
5961 }
6062
6163 [ Fact ]
62- public void GetResourceContext_Yields_Right_Type_For_IIdentifiable ( )
64+ public void GetResourceContext_Yields_Right_Type_For_Identifiable ( )
6365 {
6466 // Arrange
6567 var resourceGraphBuilder = new ResourceGraphBuilder ( new JsonApiOptions ( ) , NullLoggerFactory . Instance ) ;
@@ -80,10 +82,7 @@ private class TestContext : DbContext
8082 public DbSet < Foo > Foos { get ; set ; }
8183 }
8284
83- private class Bar : Identifiable { }
84-
85- // Used to simulate a lazy loading proxy
86- private class DummyProxy : Bar { }
85+ public class Bar : Identifiable { }
8786
8887 }
8988
0 commit comments