77using FluentAssertions ;
88using System . Collections . Generic ;
99using System . Data . Entity ;
10- using JSONAPI . Core ;
11- using Moq ;
1210
1311namespace JSONAPI . EntityFramework . Tests
1412{
1513 [ TestClass ]
16- public class EntityFrameworkMaterializerTests
14+ public class DbContextExtensionsTests
1715 {
1816 private class TestDbContext : DbContext
1917 {
@@ -60,12 +58,8 @@ private void CleanupTest()
6058 [ TestMethod ]
6159 public void GetKeyNamesStandardIdTest ( )
6260 {
63- // Arrange
64- var mockMetadataManager = new Mock < IMetadataManager > ( MockBehavior . Strict ) ;
65- var materializer = new EntityFrameworkMaterializer ( _context , mockMetadataManager . Object ) ;
66-
6761 // Act
68- IEnumerable < string > keyNames = materializer . GetKeyNames ( typeof ( Post ) ) . ToArray ( ) ;
62+ IEnumerable < string > keyNames = _context . GetKeyNames ( typeof ( Post ) ) . ToArray ( ) ;
6963
7064 // Assert
7165 keyNames . Count ( ) . Should ( ) . Be ( 1 ) ;
@@ -75,12 +69,8 @@ public void GetKeyNamesStandardIdTest()
7569 [ TestMethod ]
7670 public void GetKeyNamesNonStandardIdTest ( )
7771 {
78- // Arrange
79- var mockMetadataManager = new Mock < IMetadataManager > ( MockBehavior . Strict ) ;
80- var materializer = new EntityFrameworkMaterializer ( _context , mockMetadataManager . Object ) ;
81-
8272 // Act
83- IEnumerable < string > keyNames = materializer . GetKeyNames ( typeof ( Backlink ) ) . ToArray ( ) ;
73+ IEnumerable < string > keyNames = _context . GetKeyNames ( typeof ( Backlink ) ) . ToArray ( ) ;
8474
8575 // Assert
8676 keyNames . Count ( ) . Should ( ) . Be ( 1 ) ;
@@ -90,12 +80,8 @@ public void GetKeyNamesNonStandardIdTest()
9080 [ TestMethod ]
9181 public void GetKeyNamesNotAnEntityTest ( )
9282 {
93- // Arrange
94- var mockMetadataManager = new Mock < IMetadataManager > ( MockBehavior . Strict ) ;
95- var materializer = new EntityFrameworkMaterializer ( _context , mockMetadataManager . Object ) ;
96-
9783 // Act
98- Action action = ( ) => materializer . GetKeyNames ( typeof ( NotAnEntity ) ) ;
84+ Action action = ( ) => _context . GetKeyNames ( typeof ( NotAnEntity ) ) ;
9985 action . ShouldThrow < ArgumentException > ( ) . Which . Message . Should ( ) . Be ( "The Type NotAnEntity was not found in the DbContext with Type TestDbContext" ) ;
10086 }
10187 }
0 commit comments