public void ParseValue_Local_DateTime() { // arrange DateTimeType dateTimeType = new DateTimeType(); DateTime dateTime = new DateTime(2018, 6, 11, 8, 46, 14, DateTimeKind.Local); DateTimeOffset offset = dateTime; DateTime offsetDateTime = offset.DateTime; // act StringValueNode stringLiteral = (StringValueNode)dateTimeType.ParseValue(dateTime); StringValueNode stringLiteralOffset = (StringValueNode)dateTimeType.ParseValue(offsetDateTime); // assert Assert.Equal(stringLiteral, stringLiteralOffset); }
public void ParseValue_Unspecified_DateTime() { // arrange var dateTimeType = new DateTimeType(); var dateTime = new DateTime(2018, 6, 11, 8, 46, 14, DateTimeKind.Unspecified); DateTimeOffset offset = dateTime; DateTime offsetDateTime = offset.DateTime; // act var stringLiteral = (StringValueNode)dateTimeType.ParseValue(dateTime); var stringLiteralOffset = (StringValueNode)dateTimeType.ParseValue(offsetDateTime); // assert Assert.Equal(stringLiteralOffset, stringLiteral); }
public void ParseValue_Null() { // arrange var dateTimeType = new DateTimeType(); // act IValueNode literal = dateTimeType.ParseValue(null); // assert Assert.IsType <NullValueNode>(literal); }
public void ParseValue_Utc_DateTimeOffset() { // arrange var dateTimeType = new DateTimeType(); DateTimeOffset dateTime = new DateTime(2018, 6, 11, 8, 46, 14, DateTimeKind.Utc); string expectedLiteralValue = "2018-06-11T08:46:14.000Z"; // act var stringLiteral = (StringValueNode)dateTimeType.ParseValue(dateTime); // assert Assert.Equal(expectedLiteralValue, stringLiteral.Value); }
public void ParseValue_DateTime() { // arrange DateTimeType dateTimeType = new DateTimeType(); DateTime dateTime = new DateTime(2018, 6, 11, 8, 46, 14, DateTimeKind.Utc); string expectedLiteralValue = "2018-06-11T08:46:14+00:00"; // act StringValueNode stringLiteral = (StringValueNode)dateTimeType.ParseValue(dateTime); // assert Assert.Equal(expectedLiteralValue, stringLiteral.Value); }
public void ParseValue_DateTimeOffset() { // arrange var dateTimeType = new DateTimeType(); var dateTime = new DateTimeOffset( new DateTime(2018, 6, 11, 8, 46, 14), new TimeSpan(4, 0, 0)); string expectedLiteralValue = "2018-06-11T08:46:14.000+04:00"; // act var stringLiteral = (StringValueNode)dateTimeType.ParseValue(dateTime); // assert Assert.Equal(expectedLiteralValue, stringLiteral.Value); }