protected void LocalTime_ExpectParseLiteralToThrowSerializationException() { // arrange ScalarType scalar = CreateType <LocalTimeType>(); var valueSyntax = new StringValueNode("foo"); // act Exception?result = Record.Exception(() => scalar.ParseLiteral(valueSyntax)); // assert Assert.IsType <SerializationException>(result); }
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 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 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_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_ExpectParseLiteralToMatch() { // arrange ScalarType scalar = CreateType <LocalCurrencyType>(); var valueSyntax = new StringValueNode("$24.99"); const decimal expectedResult = 24.99m; // act object result = (decimal)scalar.ParseLiteral(valueSyntax) !; // assert Assert.Equal(expectedResult, result); }
protected void ExpectParseLiteralToMatch <TType>( IValueNode valueSyntax, object?expectedResult) where TType : ScalarType { // arrange ScalarType scalar = CreateType <TType>(); // act object?result = scalar.ParseLiteral(valueSyntax); // assert Assert.Equal(expectedResult, result); }