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 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 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 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 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 ExpectParseValueToThrowSerializationException <TType>(object?runtimeValue) where TType : ScalarType { // arrange ScalarType scalar = CreateType <TType>(); // act Exception?result = Record.Exception(() => scalar.ParseValue(runtimeValue)); // assert Assert.IsType <SerializationException>(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()); }
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 ExpectParseValueToMatchType <TType>( object?valueSyntax, Type type) where TType : ScalarType { // arrange ScalarType scalar = CreateType <TType>(); // act IValueNode result = scalar.ParseValue(valueSyntax); // assert Assert.Equal(type, result.GetType()); }