Example #1
0
        public void converts_double_to_float_value()
        {
            double val    = 0.42;
            var    result = new FloatGraphType().ToAST(val);

            result.ShouldNotBeNull();
            result.ShouldBeOfType <FloatValue>().Value.ShouldBe(val);
        }
    public void BadFloatValues()
    {
        var type = new FloatGraphType();

        var value1 = new GraphQLFloatValue(_maxNumber);
        var value2 = new GraphQLFloatValue(_minNumber);

        type.CanParseLiteral(value1).ShouldBeFalse();
        type.CanParseLiteral(value2).ShouldBeFalse();

        Should.Throw <InvalidOperationException>(() => type.ParseLiteral(value1)).Message.ShouldStartWith("Unable to convert '1797693134862320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0' literal from AST representation to the scalar type 'Float'");
        Should.Throw <InvalidOperationException>(() => type.ParseLiteral(value2)).Message.ShouldStartWith("Unable to convert '-1797693134862320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0' literal from AST representation to the scalar type 'Float'");
    }