Skip to content

Commit

Permalink
Merge pull request #4 from bobhonores/dev/2016.11.28_Add_Support_For_…
Browse files Browse the repository at this point in the history
…Nullable

Update ResourceConverterExtenstions.cs
  • Loading branch information
eoin55 authored Nov 28, 2016
2 parents dd58ae5 + 2711934 commit c788aed
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
7 changes: 6 additions & 1 deletion Src/HoneyBear.HalClient.Unit.Tests/HalClientTestContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public HalClientTestContext()
_http = _fixture.Freeze<IJsonHttpClient>();

_version = _fixture.Create<Version>();
_order = _fixture.Create<Order>();
_order = _fixture.Build<Order>().With(x => x.DeliveryDate, null).Create();
_orderItem = _fixture.Create<OrderItem>();
_paged = _fixture.Create<PagedList>();
OrderAdd = _fixture.Create<OrderAdd>();
Expand Down Expand Up @@ -361,6 +361,7 @@ private object CreateSingleResourceJson() =>
_order.OrderRef,
_order.OrderNumber,
_order.Status,
_order.DeliveryDate,
_order.Total,
_links =
new
Expand Down Expand Up @@ -400,6 +401,7 @@ private object CreateSingleResourceJsonWithoutCurie() =>
_order.OrderRef,
_order.OrderNumber,
_order.Status,
_order.DeliveryDate,
_order.Total,
_links =
new
Expand Down Expand Up @@ -492,6 +494,7 @@ private object CreatePagedResourceWithEmbeddedArrayOfResourcesJson() =>
_order.OrderRef,
_order.OrderNumber,
_order.Status,
_order.DeliveryDate,
_order.Total,
_links =
new
Expand Down Expand Up @@ -533,6 +536,7 @@ private object CreatePagedResourceWithLinkedArrayOfResourcesJson() =>
_order.OrderRef,
_order.OrderNumber,
_order.Status,
_order.DeliveryDate,
_order.Total,
_links =
new
Expand Down Expand Up @@ -607,6 +611,7 @@ private object CreateDefaultPagedResourceJson() =>
_order.OrderRef,
_order.OrderNumber,
_order.Status,
_order.DeliveryDate,
_order.Total,
_links =
new
Expand Down
3 changes: 2 additions & 1 deletion Src/HoneyBear.HalClient.Unit.Tests/ProxyResources/Order.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ internal static T Data<T>(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);
}
Expand All @@ -52,4 +54,4 @@ public static IEnumerable<T> Data<T>(this IEnumerable<IResource<T>> source)
where T : class, new()
=> source.Select(s => s.Data);
}
}
}

0 comments on commit c788aed

Please sign in to comment.