Skip to content

Commit 2fd9eb3

Browse files
committed
test(no-ef): validate the response body
1 parent 7c20d77 commit 2fd9eb3

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

test/JsonApiDotNetCoreExampleTests/Acceptance/Extensibility/NoEntityFrameworkTests.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
using System.Threading.Tasks;
1010
using System.Net;
1111
using System;
12-
using System.Diagnostics;
12+
using Newtonsoft.Json;
13+
using JsonApiDotNetCore.Models;
14+
using System.Collections.Generic;
1315

1416
namespace JsonApiDotNetCoreExampleTests.Acceptance.Extensibility
1517
{
@@ -32,12 +34,28 @@ public async Task Can_Implement_Custom_IResourceService_Without_EFAsync()
3234
// act
3335
var response = await client.SendAsync(request);
3436
var responseBody = await response.Content.ReadAsStringAsync();
35-
Console.WriteLine(responseBody);
3637
var deserializedBody = server.GetService<IJsonApiDeSerializer>()
3738
.DeserializeList<MyModel>(responseBody);
39+
40+
var expectedBody = JsonConvert.SerializeObject(new Documents {
41+
Data = new List<DocumentData> {
42+
new DocumentData {
43+
Id = "1",
44+
Type = "my-models",
45+
Attributes = new Dictionary<string, object> {
46+
{"description", "description"}
47+
}
48+
}
49+
}
50+
}, new JsonSerializerSettings {
51+
NullValueHandling = NullValueHandling.Ignore
52+
})
53+
.Replace(" ", string.Empty)
54+
.ToLower();
3855

3956
// assert
4057
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
58+
Assert.Equal(expectedBody, responseBody);
4159
}
4260
}
4361
}

0 commit comments

Comments
 (0)