private void CompleteDefaultValue( ITypeInitializationContext context, IInputType type) { try { if (DefaultValue == null) { if (_nativeDefaultValue == null) { DefaultValue = new NullValueNode(); } else { DefaultValue = type.ParseValue(_nativeDefaultValue); } } } catch (Exception ex) { context.ReportError(new SchemaError( "Could not parse the native value of input field " + $"`{context.Type.Name}.{Name}`.", context.Type, ex)); } }
private void CompleteDefaultValue( IInputType type, Action <SchemaError> reportError, INamedType parentType) { try { if (DefaultValue == null) { if (_nativeDefaultValue == null) { DefaultValue = new NullValueNode(); } else { DefaultValue = type.ParseValue(_nativeDefaultValue); } } } catch (Exception ex) { reportError(new SchemaError( "Could not parse the native value for input field " + $"`{parentType.Name}.{Name}`.", parentType, ex)); } }
internal void CompleteInputField( ITypeRegistry typeRegistry, Action <SchemaError> reportError, INamedType parentType) { _type = _typeFactory(typeRegistry); if (_type == null) { reportError(new SchemaError( $"The type of the input field {Name} is null.", parentType)); } if (_defaultValueFactory == null) { DefaultValue = new NullValueNode(null); } else { DefaultValue = _defaultValueFactory(typeRegistry); } if (parentType is InputObjectType && Property == null && typeRegistry.TryGetTypeBinding(parentType, out InputObjectTypeBinding binding) && binding.Fields.TryGetValue(Name, out InputFieldBinding fieldBinding)) { Property = fieldBinding.Property; } }
/// <summary> /// Processes the queue as far as it needs to to generate a fully qualiffied /// <see cref="SyntaxNode" /> based on its ruleset. /// </summary> /// <param name="tokenStream">The token stream.</param> /// <returns>LexicalToken.</returns> public SyntaxNode MakeNode(TokenStream tokenStream) { tokenStream.MatchOrThrow <NullToken>(); var node = new NullValueNode(tokenStream.Location); tokenStream.Next(); return(node); }
public void ParseLiteral_NullType_Null() { var type = new GeoJsonPositionType(); NullValueNode coordinate = NullValueNode.Default; object?result = type.ParseLiteral(coordinate); Assert.Null(result); }
public void TestTimeSpanTypeParseValue() { var nullValueNode = new NullValueNode(null); var timeSpanValueNode = new TimeSpanValueNode(NodeKind.ScalarTypeDefinition, TimeSpan.Parse("01:01:01"), null); Assert.IsInstanceOfType(nullValueNode, TimeSpanType.ParseValue("").GetType()); Assert.IsInstanceOfType(timeSpanValueNode, TimeSpanType.ParseValue("01:01:01").GetType()); Assert.IsInstanceOfType(timeSpanValueNode, TimeSpanType.ParseValue("01:01:01").GetType()); Assert.ThrowsException <ArgumentException>(() => TimeSpanType.ParseValue("undefined")); }
public ArgumentDescriptor(string argumentName, Type argumentType) : this(argumentName) { if (argumentType == null) { throw new ArgumentNullException(nameof(argumentType)); } TypeReference = new TypeReference(argumentType); DefaultValue = new NullValueNode(); }
public void IsInstanceOfType_NullValueNode() { // arrange StringType type = new StringType(); NullValueNode input = NullValueNode.Default; // act bool result = type.IsInstanceOfType(input); // assert Assert.True(result); }
public void ParseLiteral_NullValueNode() { // arrange StringType type = new StringType(); NullValueNode input = NullValueNode.Default; // act object output = type.ParseLiteral(input); // assert Assert.Null(output); }
public void ParseLiteral_NullValueNode() { // arrange DateType dateType = new DateType(); NullValueNode literal = new NullValueNode(); // act object value = dateType.ParseLiteral(literal); // assert Assert.Null(value); }
public void ParseLiteral_NullValueNode() { // arrange var type = new MultiplierPathType(); NullValueNode input = NullValueNode.Default; // act object output = type.ParseLiteral(input); // assert Assert.Null(output); }
public void ParseLiteral_NullValueNode() { // arrange var uuidType = new UuidType(); NullValueNode literal = NullValueNode.Default; // act var value = uuidType.ParseLiteral(literal); // assert Assert.Null(value); }
public void IsInstanceOfType_NullValueNode() { // arrange TType type = new TType(); NullValueNode input = new NullValueNode(); // act bool result = type.IsInstanceOfType(input); // assert Assert.True(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); }
public void IsInstanceOfType_NullValueNode() { // arrange var type = new TScalar(); NullValueNode input = NullValueNode.Default; // act var result = type.IsInstanceOfType(input); // assert Assert.True(result); }
public void ParseLiteral_NullValueNode() { // arrange var type = new TScalar(); NullValueNode input = NullValueNode.Default; // act var output = type.ParseLiteral(input); // assert Assert.Null(output); }
public void IsInstanceOfType_NullLiteral() { // arrange var uuidType = new UuidType(); var literal = new NullValueNode(null); // act var isOfType = uuidType.IsInstanceOfType(literal); // assert Assert.True(isOfType); }
public void ParseLiteral_NullValueNode() { // arrange UrlType urlType = new UrlType(); NullValueNode literal = NullValueNode.Default; // act object value = urlType.ParseLiteral(literal); // assert Assert.Null(value); }
public void IsInstanceOfType_NullValueNode() { // arrange var type = new MultiplierPathType(); NullValueNode input = NullValueNode.Default; // act bool result = type.IsInstanceOfType(input); // assert Assert.True(result); }
public void ParseLiteral_NullValueNode() { // arrange var dateTimeType = new DateTimeType(); NullValueNode literal = NullValueNode.Default; // act object value = dateTimeType.ParseLiteral(literal); // assert Assert.Null(value); }
public void ParseLiteral_NullValueNode() { // arrange FloatType type = new FloatType(); NullValueNode input = new NullValueNode(); // act object output = type.ParseLiteral(input); // assert Assert.Null(output); }
public void IsInstanceOfType_NullLiteral() { // arrange var byteArrayType = new ByteArrayType(); var literal = new NullValueNode(null); // act bool isOfType = byteArrayType.IsInstanceOfType(literal); // assert Assert.True(isOfType); }
public void IsInstanceOfType_NullType_True() { // arrange var type = new GeoJsonPositionType(); NullValueNode coordinate = NullValueNode.Default; // act bool?result = type.IsInstanceOfType(coordinate); // assert Assert.True(result); }
public void Matrix_Can_Be_Coerced_From_Null() { // arrange var inputParser = new InputParser(new DefaultTypeConverter()); var type = (IInputType) new ListType(new ListType(new BooleanType())); NullValueNode value = NullValueNode.Default; // act var coercedValue = inputParser.ParseLiteral(value, type, Path.New("root")); // assert Assert.Null(coercedValue); }
public void ParseScalarNullValue() { // arrange var sourceType = new IntType(); var targetType = typeof(int); NullValueNode literal = NullValueNode.Default; // act object result = ValueDeserializer .ParseLiteral(sourceType, targetType, literal); // assert Assert.Null(result); }
IInputFieldDescriptor IInputFieldDescriptor.DefaultValue(object defaultValue) { if (defaultValue == null) { DefaultValue = new NullValueNode(); NativeDefaultValue = null; } else { NativeDefaultValue = defaultValue; DefaultValue = null; TypeReference = TypeReference.GetMoreSpecific(defaultValue.GetType()); } return(this); }
protected bool TryParseValue(object value, out IValueNode valueNode) { if (value == null) { valueNode = new NullValueNode(null); return(true); } if (TrySerialize(value, out string serializedValue)) { valueNode = new StringValueNode(serializedValue); return(true); } valueNode = null; return(false); }
public void IsInstanceOfType() { // arrange BooleanValueNode boolLiteral = new BooleanValueNode(null, true); StringValueNode stringLiteral = new StringValueNode(null, "12345", false); NullValueNode nullLiteral = NullValueNode.Default; // act BooleanType booleanType = new BooleanType(); bool isIntLiteralInstanceOf = booleanType.IsInstanceOfType(boolLiteral); bool isStringLiteralInstanceOf = booleanType.IsInstanceOfType(stringLiteral); bool isNullLiteralInstanceOf = booleanType.IsInstanceOfType(nullLiteral); // assert Assert.True(isIntLiteralInstanceOf); Assert.False(isStringLiteralInstanceOf); Assert.True(isNullLiteralInstanceOf); }
public void IsInstanceOfType() { // arrange IntValueNode intLiteral = new IntValueNode(null, "12345"); StringValueNode stringLiteral = new StringValueNode(null, "12345", false); NullValueNode nullLiteral = new NullValueNode(null); // act IntType integerType = new IntType(); bool isIntLiteralInstanceOf = integerType.IsInstanceOfType(intLiteral); bool isStringLiteralInstanceOf = integerType.IsInstanceOfType(stringLiteral); bool isNullLiteralInstanceOf = integerType.IsInstanceOfType(nullLiteral); // assert Assert.True(isIntLiteralInstanceOf); Assert.False(isStringLiteralInstanceOf); Assert.True(isNullLiteralInstanceOf); }
public ArgumentDescriptor(string argumentName) { if (string.IsNullOrEmpty(argumentName)) { throw new ArgumentException( "The argument name cannot be null or empty.", nameof(argumentName)); } if (!ValidationHelper.IsFieldNameValid(argumentName)) { throw new ArgumentException( "The specified name is not a valid GraphQL argument name.", nameof(argumentName)); } Name = argumentName; DefaultValue = new NullValueNode(); }