public void ExceptionWithHandler() { using (CaptureConsole) { // create the plugin object: var plugin = new BadImplementationwithHandler(); // create the host's duck typed version of the plugin: var duckTypedPlugin = plugin.As <IPluginInterfaceWithHandler>(); // create the host's actual implementation of the request var request = new HostImplementationOfRequest(); // the host should call the method on the plugin: var result = duckTypedPlugin.DoSomething("try this", request); // result from a duck typed object throwing an exception should be null. Assert.Null(result); Ensure("BadImplementationwithHandlerCalled", "The method should get called, up to the point of the exception."); Ensure("UnhandledExceptionCalled", "When we specify an OnUnhandledException method in the host interface, and the client implements it, we should make sure it gets called."); } }
public void ExceptionWithHandler() { using (CaptureConsole) { // create the plugin object: var plugin = new BadImplementationwithHandler(); // create the host's duck typed version of the plugin: var duckTypedPlugin = plugin.As<IPluginInterfaceWithHandler>(); // create the host's actual implementation of the request var request = new HostImplementationOfRequest(); // the host should call the method on the plugin: var result = duckTypedPlugin.DoSomething("try this", request); // result from a duck typed object throwing an exception should be null. Assert.Null(result); Ensure("BadImplementationwithHandlerCalled", "The method should get called, up to the point of the exception."); Ensure("UnhandledExceptionCalled", "When we specify an OnUnhandledException method in the host interface, and the client implements it, we should make sure it gets called."); } }