public void ProviderLoadLog_TypeLoadException() { var path = FactoryProviderTypeLoadErrorPath; var catalogLog = new MockLogger(); var container = InterpreterCatalog.CreateContainer( catalogLog, FactoryProviderTypeLoadErrorPath, typeof(IInterpreterOptionsService).Assembly.Location, typeof(IInterpreterRegistryService).Assembly.Location, GetType().Assembly.Location ); var log = container.GetExport<MockLogger>().Value; var service = container.GetExportedValue<IInterpreterOptionsService>(); var registry = container.GetExportedValue<IInterpreterRegistryService>(); foreach (var interpreter in registry.Configurations) { Console.WriteLine(interpreter); } bool isMatch = false; foreach (var msg in log.AllItems) { Console.WriteLine(msg); isMatch |= new Regex(@"Failed to get interpreter factory value:.*System\.ComponentModel\.Composition\.CompositionException").IsMatch(msg); } Assert.IsTrue(isMatch); Assert.IsNotNull(registry.Configurations.FirstOrDefault()); }
public void ProviderLoadLog_SuccessAndFailure() { var path = FactoryProviderTypeLoadErrorPath; var catalogLog = new MockLogger(); var container = InterpreterCatalog.CreateContainer( catalogLog, FactoryProviderTypeLoadErrorPath, FactoryProviderSuccessPath, typeof(IInterpreterOptionsService).Assembly.Location, typeof(IInterpreterRegistryService).Assembly.Location, GetType().Assembly.Location ); var log = container.GetExport<MockLogger>().Value; var service = container.GetExportedValue<IInterpreterOptionsService>(); var registry = container.GetExportedValue<IInterpreterRegistryService>(); foreach (var interpreter in registry.Configurations) { Console.WriteLine(interpreter); } foreach (var item in log.AllItems) { Console.WriteLine(item); } Assert.AreEqual(1, log.AllItems.Count); }
public void ProviderLoadLog_CorruptImage() { var catalogLog = new MockLogger(); var path = Path.ChangeExtension(Path.GetTempFileName(), "dll"); File.Delete(path); Assert.IsFalse(File.Exists(path)); var container = InterpreterCatalog.CreateContainer( catalogLog, typeof(IInterpreterOptionsService).Assembly.Location, typeof(IInterpreterRegistryService).Assembly.Location, GetType().Assembly.Location, FactoryProviderCorruptPath ); var log = container.GetExport<MockLogger>().Value; var service = container.GetExportedValue<IInterpreterOptionsService>(); var registry = container.GetExportedValue<IInterpreterRegistryService>(); foreach (var interpreter in registry.Configurations) { Console.WriteLine(interpreter); } var error = catalogLog.AllItems.Single(); Assert.IsTrue(error.StartsWith("Failed to load interpreter provider assembly")); Assert.AreNotEqual(-1, error.IndexOf("System.BadImageFormatException: ")); }