protected void LocalCurrency_ParseResult_Null() { // arrange ScalarType scalar = CreateType <LocalCurrencyType>(); // act IValueNode result = scalar.ParseResult(null); // assert Assert.Equal(NullValueNode.Default, result); }
protected void LocalTime_ExpectSerializeToThrowSerializationException() { // arrange ScalarType scalar = CreateType <LocalTimeType>(); // act Exception?result = Record.Exception(() => scalar.Serialize("foo")); // assert Assert.IsType <SerializationException>(result); }
protected void UtcOffset_ExpectParseLiteralToThrowSerializationException() { // arrange ScalarType scalar = CreateType <UtcOffsetType>(); var valueSyntax = new StringValueNode("+17:00"); // act Exception?result = Record.Exception(() => scalar.ParseLiteral(valueSyntax)); // assert Assert.IsType <SerializationException>(result); }
protected void LocalCurrency_ExpectIsStringValueToMatch() { // arrange ScalarType scalar = CreateType <LocalCurrencyType>(); var valueSyntax = new StringValueNode("$10.99"); // act var result = scalar.IsInstanceOfType(valueSyntax); // assert Assert.True(result); }
protected void UtcOffset_ExpectParseValueToMatchTimeSpan() { // arrange ScalarType scalar = CreateType <UtcOffsetType>(); var valueSyntax = new TimeSpan(0, 0, 0); // act IValueNode result = scalar.ParseValue(valueSyntax); // assert Assert.Equal(typeof(StringValueNode), result.GetType()); }
public void Longitude_ParseLiteral_NullValueNode() { // arrange ScalarType scalar = CreateType <LongitudeType>(); NullValueNode literal = NullValueNode.Default; // act object value = scalar.ParseLiteral(literal) !; // assert Assert.Null(value); }
protected void LocalCurrency_ExpectParseValueToMatchDecimal() { // arrange ScalarType scalar = CreateType <LocalCurrencyType>(); const decimal valueSyntax = 24.95m; // act IValueNode result = scalar.ParseValue(valueSyntax); // assert Assert.Equal(typeof(StringValueNode), result.GetType()); }
protected void UtcOffset_ExpectIsUtcOffsetToMatch() { // arrange ScalarType scalar = CreateType <UtcOffsetType>(); var valueSyntax = TimeSpan.FromHours(12); // act var result = scalar.IsInstanceOfType(valueSyntax); // assert Assert.True(result); }
protected void UtcOffset_ExpectPositiveIsStringValueToMatch() { // arrange ScalarType scalar = CreateType <UtcOffsetType>(); var valueSyntax = new StringValueNode("-00:00"); // act var result = scalar.IsInstanceOfType(valueSyntax); // assert Assert.True(result); }
protected void Longitude_ExpectParseValueToMatch(double runtime, string literal) { // arrange ScalarType scalar = CreateType <LongitudeType>(); StringValueNode expected = new(literal); // act object result = scalar.ParseValue(runtime); // assert Assert.Equal(expected, result); }
protected void LocalTime_ExpectIsStringValueToMatch() { // arrange ScalarType scalar = CreateType <LocalTimeType>(); var valueSyntax = new StringValueNode("2018-06-29T08:46:14+04:00"); // act var result = scalar.IsInstanceOfType(valueSyntax); // assert Assert.True(result); }
protected void Longitude_ExpectParseValueToMatchType() { // arrange ScalarType scalar = CreateType <LongitudeType>(); const double valueSyntax = 74.3d; // act IValueNode result = scalar.ParseValue(valueSyntax); // assert Assert.Equal(typeof(StringValueNode), result.GetType()); }
protected void LocalCurrency_ExpectDeserializeStringToMatch() { // arrange ScalarType scalar = CreateType <LocalCurrencyType>(); const decimal runtimeValue = 7.99m; // act var deserializedValue = (decimal)scalar.Deserialize("$7.99") !; // assert Assert.Equal(runtimeValue, deserializedValue); }
protected void Longitude_ExpectParseLiteralToThrowSerializationException() { // arrange ScalarType scalar = CreateType <LongitudeType>(); StringValueNode valueSyntax = new("foo"); // act Exception?result = Record.Exception(() => scalar.ParseLiteral(valueSyntax)); // assert Assert.IsType <SerializationException>(result); }
protected void ExpectParseResultToThrowSerializationException <TType>(object?runtimeValue) where TType : ScalarType { // arrange ScalarType scalar = CreateType <TType>(); // act Exception?result = Record.Exception(() => scalar.ParseResult(runtimeValue)); // assert Assert.IsType <SerializationException>(result); }
protected void LocalTime_ExpectIsDateTimeToMatch() { // arrange ScalarType scalar = CreateType <LocalTimeType>(); var valueSyntax = new DateTime(2018, 6, 29, 8, 46, 14); // act var result = scalar.IsInstanceOfType(valueSyntax); // assert Assert.True(result); }
protected void Longitude_ExpectIsStringInstanceToMatch() { // arrange ScalarType scalar = CreateType <LongitudeType>(); StringValueNode valueSyntax = new("179° 0' 0.000\" E")!; // act var result = scalar.IsInstanceOfType(valueSyntax); // assert Assert.True(result); }
protected void Longitude_ExpectParseValueToThrowSerializationException_LessThanMin() { // arrange ScalarType scalar = CreateType <LongitudeType>(); const double runtimeValue = -181d; // act Exception?result = Record.Exception(() => scalar.ParseValue(runtimeValue)); // assert Assert.IsType <SerializationException>(result); }
protected void LocalTime_ExpectParseValueToThrowSerializationException() { // arrange ScalarType scalar = CreateType <LocalTimeType>(); var runtimeValue = new StringValueNode("foo"); // act Exception?result = Record.Exception(() => scalar.ParseValue(runtimeValue)); // assert Assert.IsType <SerializationException>(result); }
protected void LocalTime_ExpectDeserializeToThrowSerializationException() { // arrange ScalarType scalar = CreateType <LocalTimeType>(); object runtimeValue = new IntValueNode(1); // act Exception?result = Record.Exception(() => scalar.Deserialize(runtimeValue)); // assert Assert.IsType <SerializationException>(result); }
protected void LocalTime_ExpectParseValueToMatchDateTime() { // arrange ScalarType scalar = CreateType <LocalTimeType>(); var valueSyntax = new DateTime(2018, 6, 29, 8, 46, 14); // act IValueNode result = scalar.ParseValue(valueSyntax); // assert Assert.Equal(typeof(StringValueNode), result.GetType()); }
protected void Longitude_ExpectIsDoubleInstanceToFail_GreaterThanMax() { // arrange ScalarType scalar = CreateType <LongitudeType>(); const double valueSyntax = 181d; // act var result = scalar.IsInstanceOfType(valueSyntax); // assert Assert.False(result); }
protected void Longitude_ExpectIsDoubleInstanceToMatch() { // arrange ScalarType scalar = CreateType <LongitudeType>(); const double valueSyntax = -179d; // act var result = scalar.IsInstanceOfType(valueSyntax); // assert Assert.True(result); }
protected void UtcOffset_ExpectParseLiteralToMatch() { // arrange ScalarType scalar = CreateType <UtcOffsetType>(); var valueSyntax = new StringValueNode("-12:00"); var expectedResult = new TimeSpan(-12, 0, 0); // act object result = (TimeSpan)scalar.ParseLiteral(valueSyntax) !; // assert Assert.Equal(expectedResult, result); }
protected void LocalCurrency_ExpectDeserializeDecimalToMatch() { // arrange ScalarType scalar = CreateType <LocalCurrencyType>(); object resultValue = 0.99m; // act object?result = scalar.Deserialize(resultValue); // assert Assert.Equal(resultValue, result); }
protected void LocalTime_ExpectDeserializeDateTimeToMatch() { // arrange ScalarType scalar = CreateType <LocalTimeType>(); object resultValue = new DateTime(2018, 6, 11, 8, 46, 14, DateTimeKind.Utc); // act object?result = scalar.Deserialize(resultValue); // assert Assert.Equal(resultValue, result); }
protected void ExpectParseLiteralToThrowSerializationException <TType>( IValueNode valueSyntax) where TType : ScalarType { // arrange ScalarType scalar = CreateType <TType>(); // act Exception?result = Record.Exception(() => scalar.ParseLiteral(valueSyntax)); // assert Assert.IsType <SerializationException>(result); }
protected void UtcOffset_ExpectDeserializeTimeSpanToMatch() { // arrange ScalarType scalar = CreateType <UtcOffsetType>(); object resultValue = new TimeSpan(4, 0, 0); object runtimeValue = new TimeSpan(4, 0, 0); // act object?result = scalar.Deserialize(resultValue); // assert Assert.Equal(result, runtimeValue); }
protected void LocalTime_ExpectParseLiteralToMatch() { // arrange ScalarType scalar = CreateType <LocalTimeType>(); var valueSyntax = new StringValueNode("2018-06-29T14:46:14"); var expectedResult = new DateTime(2018, 6, 29, 14, 46, 14); // act object result = (DateTime)scalar.ParseLiteral(valueSyntax) !; // assert Assert.Equal(expectedResult, result); }
protected void UtcOffset_ExpectDeserializeStringToMatch() { // arrange ScalarType scalar = CreateType <UtcOffsetType>(); var runtimeValue = new TimeSpan(4, 0, 0); // act var deserializedValue = (TimeSpan)scalar .Deserialize("+04:00") !; // assert Assert.Equal(runtimeValue, deserializedValue); }