public void ToolFormatConverter_FailsIfPluginAssemblyCannotBeLoaded() { using (var tempDir = new TempDirectory()) { const string ToolName = "TestTool"; string PluginAssemblyPath = GetCurrentAssemblyPath(); string inputFilePath = tempDir.Write("input.txt", string.Empty); string outputFilePath = tempDir.Combine("output.txt"); // Unlike all the other tests, which default-construct the converter, this test // provides the converter with a delegate which simulates the failure to load the // plugin assembly. const string Message = "Something went dreadfully wrong."; AssemblyLoadFileDelegate assemblyLoadFileDelegate = path => throw new BadImageFormatException(Message); var converter = new ToolFormatConverter(assemblyLoadFileDelegate); Action action = () => converter.ConvertToStandardFormat( ToolName, inputFilePath, outputFilePath, LoggingOptions.None, OptionallyEmittedData.None, PluginAssemblyPath); // The attempt to convert the file should throw the same exception. action.Should().Throw <BadImageFormatException>().WithMessage(Message); } }
internal PluginConverterFactory( string pluginAssemblyPath, AssemblyLoadFileDelegate assemblyLoadFileDelegate = null) { this.assemblyLoadFileDelegate = assemblyLoadFileDelegate ?? Assembly.LoadFile; this.pluginAssemblyPath = pluginAssemblyPath; }
public ToolFormatConverter(AssemblyLoadFileDelegate assemblyLoadFileDelegate = null) { this.assemblyLoadFileDelegate = assemblyLoadFileDelegate; }