public void ConvertUnsupportedPrimitives_DoesntChangeStandardEdmPrimitives(object graph, string type, string value) { // Arrange & Act & Assert Assert.NotNull(type); Assert.NotNull(value); Assert.Equal(graph, ODataPrimitiveSerializer.ConvertUnsupportedPrimitives(graph, timeZoneInfo: null)); }
// gets the primitive odata uri representation. public static string GetUriRepresentationForValue(object value) { Contract.Assert(value != null); Contract.Assert(EdmLibHelpers.GetEdmPrimitiveTypeOrNull(value.GetType()) != null); value = ODataPrimitiveSerializer.ConvertUnsupportedPrimitives(value); return(ODataUriBuilder.GetUriRepresentation(value)); }
public void ConvertUnsupportedPrimitives_DoesntChangeStandardEdmPrimitives(object graph, string type, string value) { Assert.NotNull(type); Assert.NotNull(value); Assert.Equal( graph, ODataPrimitiveSerializer.ConvertUnsupportedPrimitives(graph)); }
public void ConvertUnsupportedDateTime_NonStandardEdmPrimitives(DateTime graph) { // Arrange & Act TimeZoneInfo timeZone = TimeZoneInfo.Local; object value = ODataPrimitiveSerializer.ConvertUnsupportedPrimitives(graph, timeZoneInfo: null); DateTimeOffset expected = graph.Kind == DateTimeKind.Unspecified ? new DateTimeOffset(graph, timeZone.GetUtcOffset(graph)) : TimeZoneInfo.ConvertTime(new DateTimeOffset(graph), timeZone); // Assert DateTimeOffset actual = Assert.IsType <DateTimeOffset>(value); Assert.Equal(new DateTimeOffset(graph), actual); Assert.Equal(expected, actual); }
public void ConvertUnsupportedDateTime_NonStandardEdmPrimitives_TimeZone(DateTime graph) { // Arrange TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"); DateTimeOffset expected = graph.Kind == DateTimeKind.Unspecified ? new DateTimeOffset(graph, tzi.GetUtcOffset(graph)) : TimeZoneInfo.ConvertTime(new DateTimeOffset(graph), tzi); // Act object value = ODataPrimitiveSerializer.ConvertUnsupportedPrimitives(graph, tzi); // Assert DateTimeOffset actual = Assert.IsType <DateTimeOffset>(value); Assert.Equal(expected, actual); }
public static string GetUriRepresentationForValue(object value, TimeZoneInfo timeZone) { Contract.Assert(value != null); Type type = value.GetType(); if (TypeHelper.IsEnum(type)) { value = new ODataEnumValue(value.ToString(), type.EdmFullName()); } else { value = ODataPrimitiveSerializer.ConvertUnsupportedPrimitives(value, timeZone); } return(ODataUriUtils.ConvertToUriLiteral(value, ODataVersion.V4)); }
public static object ConvertValue(object value) { Contract.Assert(value != null); Type type = value.GetType(); if (type.IsEnum) { value = new ODataEnumValue(value.ToString(), type.EdmFullName()); } else { Contract.Assert(EdmLibHelpers.GetEdmPrimitiveTypeOrNull(type) != null); value = ODataPrimitiveSerializer.ConvertUnsupportedPrimitives(value); } return(value); }
public static object ConvertValue(object value, TimeZoneInfo timeZone, IEdmModel model) { Contract.Assert(value != null); Type type = value.GetType(); if (TypeHelper.IsEnum(type)) { value = new ODataEnumValue(value.ToString(), type.EdmFullName()); } else { Contract.Assert(model.GetEdmPrimitiveTypeReference(type) != null); value = ODataPrimitiveSerializer.ConvertUnsupportedPrimitives(value, timeZone); } return(value); }
// gets the primitive odata uri representation. public static string GetUriRepresentationForValue(object value) { Contract.Assert(value != null); Type type = value.GetType(); if (type.GetTypeInfo().IsEnum) { value = new ODataEnumValue(value.ToString(), TypeExtensions.EdmFullName(type)); } else { Contract.Assert(EdmLibHelpers.GetEdmPrimitiveTypeOrNull(type) != null); value = ODataPrimitiveSerializer.ConvertUnsupportedPrimitives(value); } return(ODataUriUtils.ConvertToUriLiteral(value, ODataVersion.V4)); }
public void ConvertUnsupportedPrimitives_NonStandardEdmPrimitives(object graph, object result) { // Arrange & Act & Assert Assert.Equal(result, ODataPrimitiveSerializer.ConvertUnsupportedPrimitives(graph, timeZoneInfo: null)); }
public void ConvertUnsupportedPrimitives_NonStandardEdmPrimitives(object graph, object result) { Assert.Equal( result, ODataPrimitiveSerializer.ConvertUnsupportedPrimitives(graph)); }