Open
Description
The normal usage pattern for the library is to use the static JsonLdProcessor class. This works well for the stateless, static algorithms which make up the JSON-LD standard. However, it requires a consumer to create an injectable facade class in order to inject the APIs into consumers. e.g.
interface IJsonLdProcess {
JObject Compact(JToken input, JToken context, JsonLdOptions opts);
}
class JsonLdProcess {
JObject Compact(JToken input, JToken context, JsonLdOptions opts) {
return JsonLdProcessor.Compact(input, context, opts);
}
}
public class Consumer {
private readonly JToken _context;
private readonly IJsonLdProcess _jsonLdProcess;
public Consumer(IJsonLdProcess jsonLdProcess, JToken context) {
_jsonLdProcess = jsonLdProcess;
_context = context;
}
public JObject Execute(JObject input) =>
_jsonLdProcess.Compact(input, _context);
}
}
Can we provide the functionality exposed by JsonLdProcessor as a non-static implementation of an interface which can be mocked for purposes of unit testing / decoration.