public void UtcOffset_EnsureUtcOffsetTypeKindIsCorrect() { // arrange // act var type = new UtcOffsetType(); // assert Assert.Equal(TypeKind.Scalar, type.Kind); }
protected void UtcOffset_ExpectParseResultToMatchNull() { // arrange ScalarType scalar = new UtcOffsetType(); // act IValueNode result = scalar.ParseResult(null); // assert Assert.Equal(typeof(NullValueNode), result.GetType()); }
public void UtcOffset_ExpectDeserializeInvalidStringToTimeSpan() { // arrange ScalarType scalar = new UtcOffsetType(); // act var success = scalar.TryDeserialize("abc", out object?_); // assert Assert.False(success); }
protected void UtcOffset_ExpectParseResultToThrowSerializationException() { // arrange ScalarType scalar = new UtcOffsetType(); IValueNode runtimeValue = new IntValueNode(1); // act Exception?result = Record.Exception(() => scalar.ParseResult(runtimeValue)); // assert Assert.IsType <SerializationException>(result); }
protected void UtcOffset_ExpectParseResultToMatchStringValue() { // arrange ScalarType scalar = new UtcOffsetType(); const string valueSyntax = "-02:00"; // act IValueNode result = scalar.ParseResult(valueSyntax); // assert Assert.Equal(typeof(StringValueNode), result.GetType()); }
public void UtcOffset_ExpectDeserializeNullToNull() { // arrange ScalarType scalar = new UtcOffsetType(); // act var success = scalar.TryDeserialize(null, out object?deserialized); // assert Assert.True(success); Assert.Null(deserialized); }
public void UtcOffset_ExpectDeserializeNullableTimeSpanToTimeSpan() { // arrange ScalarType scalar = new UtcOffsetType(); TimeSpan? time = null; // act var success = scalar.TryDeserialize(time, out object?deserialized); // assert Assert.True(success); Assert.Null(deserialized); }
protected void UtcOffset_ExpectSerializeToMatch() { // arrange ScalarType scalar = new UtcOffsetType(); var dateTime = new TimeSpan(10, 0, 0); string expectedValue = "+10:00"; // act string serializedValue = (string)scalar.Serialize(dateTime) !; // assert Assert.Equal(expectedValue, serializedValue); }