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));
 }
Exemplo n.º 2
0
        // 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));
        }
Exemplo n.º 3
0
 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);
        }
Exemplo n.º 6
0
        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));
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        // 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));
 }
Exemplo n.º 11
0
 public void ConvertUnsupportedPrimitives_NonStandardEdmPrimitives(object graph, object result)
 {
     Assert.Equal(
         result,
         ODataPrimitiveSerializer.ConvertUnsupportedPrimitives(graph));
 }