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_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_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: ")); }
private ExportProvider GetExportProvider() { return(InterpreterCatalog.CreateContainer( new CatalogLog(_log), typeof(MsBuildProjectContextProvider), typeof(IInterpreterRegistryService), typeof(IInterpreterOptionsService) )); }
static CompositionContainer CreateCompositionContainer(bool defaultProviders = true) { var sp = new MockServiceProvider(); sp.Services[typeof(SVsActivityLog).GUID] = new MockActivityLog(); var settings = new MockSettingsManager(); sp.Services[typeof(SVsSettingsManager).GUID] = settings; return(InterpreterCatalog.CreateContainer(typeof(IInterpreterRegistryService), typeof(IInterpreterOptionsService))); }
public TestExecutor() { _app = VisualStudioProxy.FromEnvironmentVariable(PythonConstants.PythonToolsProcessIdEnvironmentVariable); _container = InterpreterCatalog.CreateContainer(typeof(IInterpreterRegistryService), typeof(IInterpreterOptionsService), typeof(TestExecutorProjectContext)); _interpreterService = _container.GetExportedValue <IInterpreterOptionsService>(); }
private static CompositionContainer CreateCompositionContainer() { var app = VisualStudioProxy.FromEnvironmentVariable(PythonConstants.PythonToolsProcessIdEnvironmentVariable); return(InterpreterCatalog.CreateContainer(typeof(IInterpreterRegistryService), typeof(IInterpreterOptionsService), typeof(TestDiscoverer))); }