Skip to content

Commit 90ab6e6

Browse files
committed
fix: e2e test paging
1 parent 441f538 commit 90ab6e6

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

src/JsonApiDotNetCore/Query/PageService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public PageService(IJsonApiOptions options)
2828
/// <inheritdoc/>
2929
public bool ShouldPaginate()
3030
{
31-
return !(PageSize > 0) || ((CurrentPage == 1 || CurrentPage == 0) && TotalPages <= 0);
31+
return (PageSize > 0) || ((CurrentPage == 1 || CurrentPage == 0) && TotalPages <= 0);
3232
}
3333
}
3434
}

test/JsonApiDotNetCoreExampleTests/Acceptance/Extensibility/NullValuedAttributeHandlingTests.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,14 @@ public async Task CheckNullBehaviorCombination(bool? omitNullValuedAttributes, b
6767
// Override some null handling options
6868
NullAttributeResponseBehavior nullAttributeResponseBehavior;
6969
if (omitNullValuedAttributes.HasValue && allowClientOverride.HasValue)
70-
{
7170
nullAttributeResponseBehavior = new NullAttributeResponseBehavior(omitNullValuedAttributes.Value, allowClientOverride.Value);
72-
}
7371
else if (omitNullValuedAttributes.HasValue)
74-
{
7572
nullAttributeResponseBehavior = new NullAttributeResponseBehavior(omitNullValuedAttributes.Value);
76-
}
7773
else if (allowClientOverride.HasValue)
78-
{
7974
nullAttributeResponseBehavior = new NullAttributeResponseBehavior(allowClientOverride: allowClientOverride.Value);
80-
}
8175
else
82-
{
8376
nullAttributeResponseBehavior = new NullAttributeResponseBehavior();
84-
}
77+
8578
var jsonApiOptions = _fixture.GetService<IJsonApiOptions>();
8679
jsonApiOptions.NullAttributeResponseBehavior = nullAttributeResponseBehavior;
8780
jsonApiOptions.AllowCustomQueryParameters = true;
@@ -98,7 +91,7 @@ public async Task CheckNullBehaviorCombination(bool? omitNullValuedAttributes, b
9891
var body = await response.Content.ReadAsStringAsync();
9992
var deserializeBody = JsonConvert.DeserializeObject<Document>(body);
10093

101-
// assert. does response contain a null valued attribute
94+
// assert: does response contain a null valued attribute?
10295
Assert.Equal(omitsNulls, !deserializeBody.SingleData.Attributes.ContainsKey("description"));
10396
Assert.Equal(omitsNulls, !deserializeBody.Included[0].Attributes.ContainsKey("last-name"));
10497

test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DocumentTests/Included.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,10 @@ public async Task GET_Included_Contains_SideloadeData_OneToMany()
156156
public async Task GET_Included_DoesNot_Duplicate_Records_ForMultipleRelationshipsOfSameType()
157157
{
158158
// arrange
159-
_context.People.RemoveRange(_context.People); // ensure all people have todo-items
160-
_context.TodoItems.RemoveRange(_context.TodoItems);
159+
_context.RemoveRange(_context.TodoItems);
160+
_context.RemoveRange(_context.TodoItemCollections);
161+
_context.RemoveRange(_context.People); // ensure all people have todo-items
162+
_context.SaveChanges();
161163
var person = _personFaker.Generate();
162164
var todoItem = _todoItemFaker.Generate();
163165
todoItem.Owner = person;

test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/UpdatingDataTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,13 @@ public async Task Respond_400_If_IdNotInAttributeList()
115115

116116
}
117117

118-
119118
[Fact]
120119
public async Task Can_Patch_Entity()
121120
{
122121
// arrange
123-
_context.TodoItems.RemoveRange(_context.TodoItems);
122+
_context.RemoveRange(_context.TodoItemCollections);
123+
_context.RemoveRange(_context.TodoItems);
124+
_context.RemoveRange(_context.People);
124125
_context.SaveChanges();
125126

126127
var todoItem = _todoItemFaker.Generate();

test/JsonApiDotNetCoreExampleTests/Acceptance/TestFixture.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ public IResponseDeserializer GetDeserializer()
4646
{
4747
var graph = new ResourceGraphBuilder()
4848
.AddResource<PersonRole>()
49+
.AddResource<Article>()
50+
.AddResource<Tag>()
51+
.AddResource<CamelCasedModel>()
52+
.AddResource<User>()
4953
.AddResource<Person>()
54+
.AddResource<Author>()
5055
.AddResource<Passport>()
5156
.AddResource<TodoItemClient>("todo-items")
5257
.AddResource<TodoItemCollectionClient, Guid>().Build();

0 commit comments

Comments
 (0)