public void KeyValuePairExtraction_NoExtractionFunction() { const string claimName = "PityTheFoolClaim"; var config = new ValidKeyValueClaimExtractionConfig(null, "1", ClaimLocation.Body, claimName); Assert.True(config.ClaimLocation.Equals(ClaimLocation.Body)); Assert.True(config.ExtractionType.Equals(ExtractionType.KeyValue)); try { config.GetClaimAsync("{\"title\": \"Person\",\"type\": \"LivingThing\"}").Wait(); } catch (AggregateException) { return; } Assert.True(false); }
public void KeyValuePairExtraction_Theory(string key, string data, string extractionFunction) { const string claimName = "PityTheFoolClaim"; KeyValueClaimExtractionConfig.KeyValueExtractionAsync extractionFunc = null; if (extractionFunction?.Equals(nameof(ExtractionFunctions.KeyValueFunc)) ?? false) { extractionFunc = ExtractionFunctions.KeyValueFunc; } var config = new ValidKeyValueClaimExtractionConfig(extractionFunc, key, ClaimLocation.Body, claimName); Assert.True(config.ClaimLocation.Equals(ClaimLocation.Body)); Assert.True(config.ExtractionType.Equals(ExtractionType.KeyValue)); var result = config.GetClaimAsync(data).Result; switch (key) { case "1": { Assert.Equal(claimName, result.Type); Assert.Equal("one", result.Value); break; } case "2": { Assert.Equal(claimName, result.Type); Assert.Equal("two", result.Value); break; } case "fourSeventyFive": { Assert.Equal(string.Empty, result.Value); break; } } }