Skip to content

Commit cbe01c2

Browse files
author
Bart Koelman
committed
Refactored tests for nulls/default query string parameters; removed some duplication and fixed an equality bug.
1 parent 4bdb3e8 commit cbe01c2

File tree

11 files changed

+293
-356
lines changed

11 files changed

+293
-356
lines changed

src/JsonApiDotNetCore/Serialization/Building/ResourceObjectBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private void ProcessAttributes(IIdentifiable resource, IEnumerable<AttrAttribute
146146
return;
147147
}
148148

149-
if (_settings.SerializerDefaultValueHandling == DefaultValueHandling.Ignore && value == TypeHelper.GetDefaultValue(attr.Property.PropertyType))
149+
if (_settings.SerializerDefaultValueHandling == DefaultValueHandling.Ignore && Equals(value, TypeHelper.GetDefaultValue(attr.Property.PropertyType)))
150150
{
151151
return;
152152
}

test/JsonApiDotNetCoreExampleTests/Acceptance/Extensibility/IgnoreDefaultValuesTests.cs

Lines changed: 0 additions & 172 deletions
This file was deleted.

test/JsonApiDotNetCoreExampleTests/Acceptance/Extensibility/IgnoreNullValuesTests.cs

Lines changed: 0 additions & 175 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using JsonApiDotNetCore.Resources;
3+
using JsonApiDotNetCore.Resources.Annotations;
4+
5+
namespace JsonApiDotNetCoreExampleTests.IntegrationTests.QueryStrings
6+
{
7+
public sealed class Appointment : Identifiable
8+
{
9+
[Attr]
10+
public string Title { get; set; }
11+
12+
[Attr]
13+
public DateTimeOffset StartTime { get; set; }
14+
15+
[Attr]
16+
public DateTimeOffset EndTime { get; set; }
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Collections.Generic;
2+
using JsonApiDotNetCore.Resources;
3+
using JsonApiDotNetCore.Resources.Annotations;
4+
5+
namespace JsonApiDotNetCoreExampleTests.IntegrationTests.QueryStrings
6+
{
7+
public sealed class Calendar : Identifiable
8+
{
9+
[Attr]
10+
public string TimeZone { get; set; }
11+
12+
[Attr]
13+
public int DefaultAppointmentDurationInMinutes { get; set; }
14+
15+
[HasMany]
16+
public ISet<Appointment> Appointments { get; set; }
17+
}
18+
}

0 commit comments

Comments
 (0)