public void LocalTime_ExpectDeserializeInvalidStringToDateTime() { // arrange ScalarType scalar = new LocalTimeType(); // act var success = scalar.TryDeserialize("abc", out object?_); // assert Assert.False(success); }
protected void LocalTime_ExpectParseResultToMatchNull() { // arrange ScalarType scalar = new LocalTimeType(); // act IValueNode result = scalar.ParseResult(null); // assert Assert.Equal(typeof(NullValueNode), result.GetType()); }
public void LocalTime_EnsureLocalTimeTypeKindIsCorrect() { // arrange var type = new LocalTimeType(); // act TypeKind kind = type.Kind; // assert Assert.Equal(TypeKind.Scalar, kind); }
protected void LocalTime_ExpectParseResultToThrowSerializationException() { // arrange ScalarType scalar = new LocalTimeType(); IValueNode runtimeValue = new IntValueNode(1); // act Exception?result = Record.Exception(() => scalar.ParseResult(runtimeValue)); // assert Assert.IsType <SerializationException>(result); }
protected void LocalTime_ExpectParseResultToMatchStringValue() { // arrange ScalarType scalar = new LocalTimeType(); const string valueSyntax = "2018-06-29T08:46:14+04:00"; // act IValueNode result = scalar.ParseResult(valueSyntax); // assert Assert.Equal(typeof(StringValueNode), result.GetType()); }
public void LocalTime_ExpectDeserializeNullToNull() { // arrange ScalarType scalar = new LocalTimeType(); // act var success = scalar.TryDeserialize(null, out object?deserialized); // assert Assert.True(success); Assert.Null(deserialized); }
public void LocalTime_ExpectDeserializeNullableDateTimeToDateTime() { // arrange ScalarType scalar = new LocalTimeType(); DateTime? time = null; // act var success = scalar.TryDeserialize(time, out object?deserialized); // assert Assert.True(success); Assert.Null(deserialized); }
protected void LocalTime_ExpectSerializeUtcToMatch() { // arrange ScalarType scalar = new LocalTimeType(); DateTimeOffset dateTime = new DateTime(2018, 6, 11, 8, 46, 14, DateTimeKind.Utc); const string expectedValue = "08:46:14"; // act string serializedValue = (string)scalar.Serialize(dateTime) !; // assert Assert.Equal(expectedValue, serializedValue); }
protected void LocalTime_ExpectSerializeDateTimeOffsetToMatch() { // arrange ScalarType scalar = new LocalTimeType(); var dateTime = new DateTimeOffset( new DateTime(2018, 6, 11, 8, 46, 14), new TimeSpan(4, 0, 0)); string expectedValue = "08:46:14"; // act string serializedValue = (string)scalar.Serialize(dateTime) !; // assert Assert.Equal(expectedValue, serializedValue); }
public void LocalTime_ParseLiteralStringValueDifferentCulture(string cultureName) { // arrange Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(cultureName); ScalarType scalar = new LocalTimeType(); var valueSyntax = new StringValueNode("2018-06-29T08:46:14+04:00"); var expectedDateTime = new DateTimeOffset( new DateTime(2018, 6, 29, 8, 46, 14), new TimeSpan(4, 0, 0)); // act var dateTime = (DateTime)scalar.ParseLiteral(valueSyntax) !; // assert Assert.Equal(expectedDateTime, dateTime); }