public void JsonPathExtraction_Theory(string jsonPath, string json, string extractionFunction) { const string claimName = "PityTheFoolClaim"; JsonPathClaimExtractionConfig.ExtractValueByJsonPathAsync extractionFunc = null; if (extractionFunction?.Equals(nameof(ExtractionFunctions.JsonPathFunc)) ?? false) { extractionFunc = ExtractionFunctions.JsonPathFunc; } var config = new ValidJsonPathClaimExtractionConfig(jsonPath, extractionFunc, claimName, ClaimLocation.Body); Assert.True(config.ClaimLocation.Equals(ClaimLocation.Body)); Assert.True(config.ExtractionType.Equals(ExtractionType.JsonPath)); var result = config.GetClaimAsync(json).Result; if (string.IsNullOrEmpty(jsonPath) && result != null) { Assert.Equal(result.Type, claimName); Assert.Equal("{\r\n \"returnsTheFullThing\": \"withoutHesitation\"\r\n}", result.Value); } else if (string.IsNullOrEmpty(json)) { Assert.Null(result); } else if (result != null) { Assert.Equal(result.Type, claimName); Assert.Equal("Person", result.Value); } }
/// <inheritdoc /> internal ValidJsonPathClaimExtractionConfig(string path, JsonPathClaimExtractionConfig.ExtractValueByJsonPathAsync jsonPathExtraction, string claimName, ClaimLocation location) { _path = path; _extract = jsonPathExtraction; _claimName = claimName; ClaimLocation = location; }