Skip to content

Commit 7158595

Browse files
author
Bart Koelman
committed
Simplified existing tests
1 parent 2c4e75c commit 7158595

File tree

1 file changed

+29
-30
lines changed

1 file changed

+29
-30
lines changed

test/JsonApiDotNetCoreTests/IntegrationTests/Serialization/SerializationTests.cs

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Globalization;
43
using System.Linq;
54
using System.Net;
@@ -91,13 +90,13 @@ public async Task Returns_no_body_for_failed_HEAD_request()
9190
public async Task Can_get_primary_resources_with_include()
9291
{
9392
// Arrange
94-
List<Meeting> meetings = _fakers.Meeting.Generate(1);
95-
meetings[0].Attendees = _fakers.MeetingAttendee.Generate(1);
93+
Meeting meeting = _fakers.Meeting.Generate();
94+
meeting.Attendees = _fakers.MeetingAttendee.Generate(1);
9695

9796
await _testContext.RunOnDatabaseAsync(async dbContext =>
9897
{
9998
await dbContext.ClearTableAsync<Meeting>();
100-
dbContext.Meetings.AddRange(meetings);
99+
dbContext.Meetings.Add(meeting);
101100
await dbContext.SaveChangesAsync();
102101
});
103102

@@ -117,52 +116,52 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
117116
""data"": [
118117
{
119118
""type"": ""meetings"",
120-
""id"": """ + meetings[0].StringId + @""",
119+
""id"": """ + meeting.StringId + @""",
121120
""attributes"": {
122-
""title"": """ + meetings[0].Title + @""",
123-
""startTime"": """ + meetings[0].StartTime.ToString(JsonDateTimeOffsetFormatSpecifier) + @""",
124-
""duration"": """ + meetings[0].Duration + @""",
121+
""title"": """ + meeting.Title + @""",
122+
""startTime"": """ + meeting.StartTime.ToString(JsonDateTimeOffsetFormatSpecifier) + @""",
123+
""duration"": """ + meeting.Duration + @""",
125124
""location"": {
126-
""lat"": " + meetings[0].Location.Latitude.ToString(CultureInfo.InvariantCulture) + @",
127-
""lng"": " + meetings[0].Location.Longitude.ToString(CultureInfo.InvariantCulture) + @"
125+
""lat"": " + meeting.Location.Latitude.ToString(CultureInfo.InvariantCulture) + @",
126+
""lng"": " + meeting.Location.Longitude.ToString(CultureInfo.InvariantCulture) + @"
128127
}
129128
},
130129
""relationships"": {
131130
""attendees"": {
132131
""links"": {
133-
""self"": ""http://localhost/meetings/" + meetings[0].StringId + @"/relationships/attendees"",
134-
""related"": ""http://localhost/meetings/" + meetings[0].StringId + @"/attendees""
132+
""self"": ""http://localhost/meetings/" + meeting.StringId + @"/relationships/attendees"",
133+
""related"": ""http://localhost/meetings/" + meeting.StringId + @"/attendees""
135134
},
136135
""data"": [
137136
{
138137
""type"": ""meetingAttendees"",
139-
""id"": """ + meetings[0].Attendees[0].StringId + @"""
138+
""id"": """ + meeting.Attendees[0].StringId + @"""
140139
}
141140
]
142141
}
143142
},
144143
""links"": {
145-
""self"": ""http://localhost/meetings/" + meetings[0].StringId + @"""
144+
""self"": ""http://localhost/meetings/" + meeting.StringId + @"""
146145
}
147146
}
148147
],
149148
""included"": [
150149
{
151150
""type"": ""meetingAttendees"",
152-
""id"": """ + meetings[0].Attendees[0].StringId + @""",
151+
""id"": """ + meeting.Attendees[0].StringId + @""",
153152
""attributes"": {
154-
""displayName"": """ + meetings[0].Attendees[0].DisplayName + @"""
153+
""displayName"": """ + meeting.Attendees[0].DisplayName + @"""
155154
},
156155
""relationships"": {
157156
""meeting"": {
158157
""links"": {
159-
""self"": ""http://localhost/meetingAttendees/" + meetings[0].Attendees[0].StringId + @"/relationships/meeting"",
160-
""related"": ""http://localhost/meetingAttendees/" + meetings[0].Attendees[0].StringId + @"/meeting""
158+
""self"": ""http://localhost/meetingAttendees/" + meeting.Attendees[0].StringId + @"/relationships/meeting"",
159+
""related"": ""http://localhost/meetingAttendees/" + meeting.Attendees[0].StringId + @"/meeting""
161160
}
162161
}
163162
},
164163
""links"": {
165-
""self"": ""http://localhost/meetingAttendees/" + meetings[0].Attendees[0].StringId + @"""
164+
""self"": ""http://localhost/meetingAttendees/" + meeting.Attendees[0].StringId + @"""
166165
}
167166
}
168167
]
@@ -173,12 +172,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
173172
public async Task Can_get_primary_resources_with_empty_include()
174173
{
175174
// Arrange
176-
List<Meeting> meetings = _fakers.Meeting.Generate(1);
175+
Meeting meeting = _fakers.Meeting.Generate();
177176

178177
await _testContext.RunOnDatabaseAsync(async dbContext =>
179178
{
180179
await dbContext.ClearTableAsync<Meeting>();
181-
dbContext.Meetings.AddRange(meetings);
180+
dbContext.Meetings.Add(meeting);
182181
await dbContext.SaveChangesAsync();
183182
});
184183

@@ -198,27 +197,27 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
198197
""data"": [
199198
{
200199
""type"": ""meetings"",
201-
""id"": """ + meetings[0].StringId + @""",
200+
""id"": """ + meeting.StringId + @""",
202201
""attributes"": {
203-
""title"": """ + meetings[0].Title + @""",
204-
""startTime"": """ + meetings[0].StartTime.ToString(JsonDateTimeOffsetFormatSpecifier) + @""",
205-
""duration"": """ + meetings[0].Duration + @""",
202+
""title"": """ + meeting.Title + @""",
203+
""startTime"": """ + meeting.StartTime.ToString(JsonDateTimeOffsetFormatSpecifier) + @""",
204+
""duration"": """ + meeting.Duration + @""",
206205
""location"": {
207-
""lat"": " + meetings[0].Location.Latitude.ToString(CultureInfo.InvariantCulture) + @",
208-
""lng"": " + meetings[0].Location.Longitude.ToString(CultureInfo.InvariantCulture) + @"
206+
""lat"": " + meeting.Location.Latitude.ToString(CultureInfo.InvariantCulture) + @",
207+
""lng"": " + meeting.Location.Longitude.ToString(CultureInfo.InvariantCulture) + @"
209208
}
210209
},
211210
""relationships"": {
212211
""attendees"": {
213212
""links"": {
214-
""self"": ""http://localhost/meetings/" + meetings[0].StringId + @"/relationships/attendees"",
215-
""related"": ""http://localhost/meetings/" + meetings[0].StringId + @"/attendees""
213+
""self"": ""http://localhost/meetings/" + meeting.StringId + @"/relationships/attendees"",
214+
""related"": ""http://localhost/meetings/" + meeting.StringId + @"/attendees""
216215
},
217216
""data"": []
218217
}
219218
},
220219
""links"": {
221-
""self"": ""http://localhost/meetings/" + meetings[0].StringId + @"""
220+
""self"": ""http://localhost/meetings/" + meeting.StringId + @"""
222221
}
223222
}
224223
],

0 commit comments

Comments
 (0)