@@ -70,7 +70,7 @@ public async Task Request_With_ClientGeneratedId_Returns_403()
7070 }
7171
7272 [ Fact ]
73- public async Task PostRequest_ShouldReceiveLocationHeader_InResponse ( )
73+ public async Task ShouldReceiveLocationHeader_InResponse ( )
7474 {
7575 // arrange
7676 var builder = new WebHostBuilder ( )
@@ -105,5 +105,39 @@ public async Task PostRequest_ShouldReceiveLocationHeader_InResponse()
105105 Assert . Equal ( HttpStatusCode . Created , response . StatusCode ) ;
106106 Assert . Equal ( $ "/api/v1/todo-items/{ deserializedBody . Id } ", response . Headers . Location . ToString ( ) ) ;
107107 }
108+
109+ [ Fact ]
110+ public async Task Respond_409_ToIncorrectEntityType ( )
111+ {
112+ // arrange
113+ var builder = new WebHostBuilder ( )
114+ . UseStartup < Startup > ( ) ;
115+ var httpMethod = new HttpMethod ( "POST" ) ;
116+ var route = "/api/v1/todo-items" ;
117+ var server = new TestServer ( builder ) ;
118+ var client = server . CreateClient ( ) ;
119+ var request = new HttpRequestMessage ( httpMethod , route ) ;
120+ var todoItem = _todoItemFaker . Generate ( ) ;
121+ var content = new
122+ {
123+ data = new
124+ {
125+ type = "people" ,
126+ attributes = new
127+ {
128+ description = todoItem . Description ,
129+ ordinal = todoItem . Ordinal
130+ }
131+ }
132+ } ;
133+ request . Content = new StringContent ( JsonConvert . SerializeObject ( content ) ) ;
134+ request . Content . Headers . ContentType = new MediaTypeHeaderValue ( "application/vnd.api+json" ) ;
135+
136+ // act
137+ var response = await client . SendAsync ( request ) ;
138+
139+ // assert
140+ Assert . Equal ( HttpStatusCode . Conflict , response . StatusCode ) ;
141+ }
108142 }
109143}
0 commit comments