diff --git a/Src/HoneyBear.HalClient.Unit.Tests/HalClientTestContext.cs b/Src/HoneyBear.HalClient.Unit.Tests/HalClientTestContext.cs index a352742..c9ec165 100644 --- a/Src/HoneyBear.HalClient.Unit.Tests/HalClientTestContext.cs +++ b/Src/HoneyBear.HalClient.Unit.Tests/HalClientTestContext.cs @@ -47,7 +47,7 @@ public HalClientTestContext() _http = _fixture.Freeze(); _version = _fixture.Create(); - _order = _fixture.Create(); + _order = _fixture.Build().With(x => x.DeliveryDate, null).Create(); _orderItem = _fixture.Create(); _paged = _fixture.Create(); OrderAdd = _fixture.Create(); @@ -361,6 +361,7 @@ private object CreateSingleResourceJson() => _order.OrderRef, _order.OrderNumber, _order.Status, + _order.DeliveryDate, _order.Total, _links = new @@ -400,6 +401,7 @@ private object CreateSingleResourceJsonWithoutCurie() => _order.OrderRef, _order.OrderNumber, _order.Status, + _order.DeliveryDate, _order.Total, _links = new @@ -492,6 +494,7 @@ private object CreatePagedResourceWithEmbeddedArrayOfResourcesJson() => _order.OrderRef, _order.OrderNumber, _order.Status, + _order.DeliveryDate, _order.Total, _links = new @@ -533,6 +536,7 @@ private object CreatePagedResourceWithLinkedArrayOfResourcesJson() => _order.OrderRef, _order.OrderNumber, _order.Status, + _order.DeliveryDate, _order.Total, _links = new @@ -607,6 +611,7 @@ private object CreateDefaultPagedResourceJson() => _order.OrderRef, _order.OrderNumber, _order.Status, + _order.DeliveryDate, _order.Total, _links = new diff --git a/Src/HoneyBear.HalClient.Unit.Tests/ProxyResources/Order.cs b/Src/HoneyBear.HalClient.Unit.Tests/ProxyResources/Order.cs index 3f761cf..b49234a 100644 --- a/Src/HoneyBear.HalClient.Unit.Tests/ProxyResources/Order.cs +++ b/Src/HoneyBear.HalClient.Unit.Tests/ProxyResources/Order.cs @@ -8,6 +8,7 @@ internal class Order public Guid OrderRef { get; set; } public string OrderNumber { get; set; } public string Status { get; set; } + public DateTime? DeliveryDate { get; set; } public Money Total { get; set; } } -} \ No newline at end of file +} diff --git a/Src/HoneyBear.HalClient/Models/ResourceConverterExtenstions.cs b/Src/HoneyBear.HalClient/Models/ResourceConverterExtenstions.cs index 42a6647..b97aa4c 100644 --- a/Src/HoneyBear.HalClient/Models/ResourceConverterExtenstions.cs +++ b/Src/HoneyBear.HalClient/Models/ResourceConverterExtenstions.cs @@ -33,8 +33,10 @@ internal static T Data(this IResource source) value = complex.ToObject(propertyType); else if (array != null) value = array.ToObject(propertyType); - else + else if (pair.Value != null) value = TypeDescriptor.GetConverter(propertyType).ConvertFromInvariantString(pair.Value.ToString()); + else + value = null; property.SetValue(data, value, null); } @@ -52,4 +54,4 @@ public static IEnumerable Data(this IEnumerable> source) where T : class, new() => source.Select(s => s.Data); } -} \ No newline at end of file +}