コード例 #1
0
        public void JsonPathValidator_Fail(string jsonPath)
        {
            string errorDetails;

            Assert.False(JsonPathValidator.IsSupportedJsonPath(jsonPath, out errorDetails));
            Assert.NotEmpty(errorDetails);
        }
コード例 #2
0
        public void JsonPathValidator_Debug()
        {
            string jsonPath = "message.Weather.HistoricalData[0].Temperature[1]";

            bool isSupported = JsonPathValidator.IsSupportedJsonPath(jsonPath, out _);

            Assert.True(isSupported);
        }
コード例 #3
0
        static Expression Create(Expression[] args, Expression[] contextArgs)
        {
            var    inputExpression = args.FirstOrDefault() as ConstantExpression;
            string queryString     = inputExpression?.Value as string;

            if (string.IsNullOrEmpty(queryString))
            {
                throw new ArgumentException("$body query cannot be empty");
            }

            // Validate input string as JsonPath
            if (!JsonPathValidator.IsSupportedJsonPath(queryString, out string errorDetails))
            {
                throw new ArgumentException(
                          string.Format(CultureInfo.InvariantCulture,
                                        "Error in $body query. {0}",
                                        errorDetails));
            }

            return(Expression.Call(typeof(BodyQuery).GetMethod("Runtime", BindingFlags.NonPublic | BindingFlags.Static), args.Union(contextArgs)));
        }
コード例 #4
0
 public void JsonPathValidator_Success(string jsonPath)
 {
     Assert.True(JsonPathValidator.IsSupportedJsonPath(jsonPath, out _));
 }