Пример #1
0
 /// <summary>
 /// Either the syntax node is invalid when parsing the literal or the syntax
 /// node value has an invalid format.
 /// </summary>
 public static SerializationException FieldSet_InvalidFormat(
     FieldSetType fieldSetType) =>
 new SerializationException(
     ErrorBuilder.New()
     .SetMessage(ThrowHelper_FieldSet_HasInvalidFormat)
     .SetCode(ErrorCodes.Scalars.InvalidSyntaxFormat)
     .Build(),
     fieldSetType);
    public void Ensure_Type_Name_Is_Correct()
    {
        // arrange
        // act
        var type = new FieldSetType();

        // assert
        Assert.Equal(WellKnownTypeNames.FieldSet, type.Name);
    }
    public void ParseValue_InvalidValue()
    {
        // arrange
        var type = new FieldSetType();

        // act
        void Action() => type.ParseValue(1);

        // assert
        Assert.Throws <SerializationException>(Action);
    }
    public void ParseValue_Null()
    {
        // arrange
        var type = new FieldSetType();

        // act
        IValueNode valueSyntax = type.ParseValue(null);

        // assert
        Assert.IsType <NullValueNode>(valueSyntax);
    }
    public void Serialize_Invalid_Format()
    {
        // arrange
        var type = new FieldSetType();

        // act
        void Action() => type.Serialize(1);

        // assert
        Assert.Throws <SerializationException>(Action);
    }
    public void TryDeserialize_Null()
    {
        // arrange
        var type = new FieldSetType();

        // act
        var success = type.TryDeserialize(null, out var selectionSet);

        // assert
        Assert.True(success);
        Assert.Null(selectionSet);
    }
    public void Deserialize_Invalid_Format()
    {
        // arrange
        var          type       = new FieldSetType();
        const string serialized = "1";

        // act
        void Action() => type.Deserialize(serialized);

        // assert
        Assert.Throws <SerializationException>(Action);
    }
    public void Deserialize()
    {
        // arrange
        var          type       = new FieldSetType();
        const string serialized = "a b c d e(d: $b)";

        // act
        var selectionSet = type.Deserialize(serialized);

        // assert
        Assert.IsType <SelectionSetNode>(selectionSet);
    }
    public void TrySerialize_Invalid_Format()
    {
        // arrange
        var type = new FieldSetType();

        // act
        var success = type.TrySerialize(1, out var serialized);

        // assert
        Assert.False(success);
        Assert.Null(serialized);
    }
Пример #10
0
    public void Serialize()
    {
        // arrange
        var type = new FieldSetType();
        SelectionSetNode selectionSet = Syntax.ParseSelectionSet("{ a b c d e(d: $b) }");

        // act
        var serialized = type.Serialize(selectionSet);

        // assert
        Assert.Equal("a b c d e(d: $b)", serialized);
    }
Пример #11
0
    public void TryDeserialize_Invalid_Type()
    {
        // arrange
        var       type       = new FieldSetType();
        const int serialized = 1;

        // act
        var success = type.TryDeserialize(serialized, out var selectionSet);

        // assert
        Assert.False(success);
        Assert.Null(selectionSet);
    }
Пример #12
0
    public void TryDeserialize()
    {
        // arrange
        var          type       = new FieldSetType();
        const string serialized = "a b c d e(d: $b)";

        // act
        var success = type.TryDeserialize(serialized, out var selectionSet);

        // assert
        Assert.True(success);
        Assert.IsType <SelectionSetNode>(selectionSet);
    }
Пример #13
0
    public void TrySerialize()
    {
        // arrange
        var type = new FieldSetType();
        SelectionSetNode selectionSet = Syntax.ParseSelectionSet("{ a b c d e(d: $b) }");

        // act
        var success = type.TrySerialize(selectionSet, out var serialized);

        // assert
        Assert.True(success);
        Assert.Equal("a b c d e(d: $b)", serialized);
    }
Пример #14
0
    public void ParseValue()
    {
        // arrange
        var type = new FieldSetType();
        SelectionSetNode selectionSet = Syntax.ParseSelectionSet("{ a b c d e(d: $b) }");

        // act
        IValueNode valueSyntax = type.ParseValue(selectionSet);

        // assert
        Assert.Equal(
            "a b c d e(d: $b)",
            Assert.IsType <StringValueNode>(valueSyntax).Value);
    }