20
20
namespace JsonApiDotNetCoreExampleTests . Acceptance . Spec
21
21
{
22
22
[ Collection ( "WebHostCollection" ) ]
23
- public class UpdatingDataTests
23
+ public class UpdatingDataTests : EndToEndTest
24
24
{
25
25
private TestFixture < Startup > _fixture ;
26
26
private AppDbContext _context ;
27
27
private Faker < TodoItem > _todoItemFaker ;
28
28
private Faker < Person > _personFaker ;
29
29
30
- public UpdatingDataTests ( TestFixture < Startup > fixture )
31
- {
30
+ public UpdatingDataTests ( TestFixture < Startup > fixture ) : base ( fixture )
31
+ {
32
32
_fixture = fixture ;
33
33
_context = fixture . GetService < AppDbContext > ( ) ;
34
34
@@ -41,6 +41,25 @@ public UpdatingDataTests(TestFixture<Startup> fixture)
41
41
. RuleFor ( p => p . LastName , f => f . Name . LastName ( ) ) ;
42
42
}
43
43
44
+ [ Fact ]
45
+ public async Task PatchResource_ModelWithEntityFrameworkInHeritance_IsPatched ( )
46
+ {
47
+ // Arrange
48
+ var dbContext = PrepareTest < Startup > ( ) ;
49
+ var serializer = GetSerializer < SuperUser > ( e => new { e . SecurityLevel } ) ;
50
+ var superUser = new SuperUser { SecurityLevel = 1337 , Username = "Super" , Password = "User" } ;
51
+ dbContext . SuperUsers . Add ( superUser ) ;
52
+ dbContext . SaveChanges ( ) ;
53
+ var su = new SuperUser { Id = superUser . Id , SecurityLevel = 2674 } ;
54
+
55
+ // Act
56
+ var ( body , response ) = await Patch ( $ "/api/v1/super-users/{ su . Id } ", serializer . Serialize ( su ) ) ;
57
+
58
+ // Assert
59
+ AssertEqualStatusCode ( HttpStatusCode . OK , response ) ;
60
+ var updated = _deserializer . DeserializeSingle < SuperUser > ( body ) . Data ;
61
+ Assert . Equal ( 2674 , updated . SecurityLevel ) ;
62
+ }
44
63
45
64
[ Fact ]
46
65
public async Task Response400IfUpdatingNotSettableAttribute ( )
0 commit comments