Suppose you have a vendor application (and associated closed vendor API) which makes calls on C# 'plugin' code written by the customer. Plugins implement abstract classes defined by the vendor. For example
public class MyPlugin : AbstractVendorPlugin
{
public override VendorClass PluginMain(VendorClass vc, VendorFactory vf)
{
vc.AddCalculation("x => x*x");
ExecutionContext ec = vf.CreateExecutionContext();
vc.Execute(ec);
return vc;
}
}
The handles for the classes/factories passed into the plugin area are created by the vendor application, and cannot be created outside of that application (and let us assume that our build server cannot spontaneously create an application instance).
I am unsure of how to proceed with making the plugin code unit testable. The only option I can come up with is to wrap the objects in interfaces and then limit tests to test cases which count invocations and validate inputs on those invocations (outputs cannot be verified if they are vendor objects). This seems to not provide much value.
Is there another option here I am not seeing? Does unit testing a plugin paradigm like this even make sense?
Aucun commentaire:
Enregistrer un commentaire