1
- using System ;
2
1
using JsonApiDotNetCore . Builders ;
3
2
using JsonApiDotNetCore . Configuration ;
4
3
using JsonApiDotNetCore . Internal ;
5
4
using JsonApiDotNetCore . Models ;
6
5
using Microsoft . EntityFrameworkCore ;
7
6
using Microsoft . Extensions . Logging ;
8
7
using Microsoft . Extensions . Logging . Abstractions ;
8
+ using Castle . DynamicProxy ;
9
9
using Xunit ;
10
10
11
11
namespace UnitTests . Internal
@@ -50,16 +50,18 @@ public void GetResourceContext_Yields_Right_Type_For_Proxy()
50
50
var resourceGraphBuilder = new ResourceGraphBuilder ( new JsonApiOptions ( ) , NullLoggerFactory . Instance ) ;
51
51
resourceGraphBuilder . AddResource < Bar > ( ) ;
52
52
var resourceGraph = ( ResourceGraph ) resourceGraphBuilder . Build ( ) ;
53
+ var proxyGenerator = new ProxyGenerator ( ) ;
53
54
54
55
// Act
55
- var result = resourceGraph . GetResourceContext ( typeof ( DummyProxy ) ) ;
56
+ var proxy = proxyGenerator . CreateClassProxy < Bar > ( ) ;
57
+ var result = resourceGraph . GetResourceContext ( proxy . GetType ( ) ) ;
56
58
57
59
// Assert
58
60
Assert . Equal ( typeof ( Bar ) , result . ResourceType ) ;
59
61
}
60
62
61
63
[ Fact ]
62
- public void GetResourceContext_Yields_Right_Type_For_IIdentifiable ( )
64
+ public void GetResourceContext_Yields_Right_Type_For_Identifiable ( )
63
65
{
64
66
// Arrange
65
67
var resourceGraphBuilder = new ResourceGraphBuilder ( new JsonApiOptions ( ) , NullLoggerFactory . Instance ) ;
@@ -80,10 +82,7 @@ private class TestContext : DbContext
80
82
public DbSet < Foo > Foos { get ; set ; }
81
83
}
82
84
83
- private class Bar : Identifiable { }
84
-
85
- // Used to simulate a lazy loading proxy
86
- private class DummyProxy : Bar { }
85
+ public class Bar : Identifiable { }
87
86
88
87
}
89
88
0 commit comments