예제 #1
0
            // Coerces a scalar value
            static object ParseValueScalar(ScalarGraphType scalarGraphType, VariableName variableName, object value)
            {
                if (value == null)
                {
                    return(null);
                }

                object ret;

                try
                {
                    ret = scalarGraphType.ParseValue(value);
                }
                catch (Exception ex)
                {
                    throw new InvalidVariableError(variableName, $"Unable to convert '{value}' to '{scalarGraphType.Name}'", ex);
                }

                if (ret == null)
                {
                    throw new InvalidVariableError(variableName, $"Unable to convert '{value}' to '{scalarGraphType.Name}'");
                }

                return(ret);
            }
예제 #2
0
 protected void ShouldParseValue(TSerializedRepresentation data, TNativeRepresentation expected)
 {
     _graphType.ParseValue(data).ShouldEqual(expected);
 }