示例#1
0
        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);
        }
示例#2
0
        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());
        }
示例#3
0
        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: "));
        }
示例#4
0
 private ExportProvider GetExportProvider()
 {
     return(InterpreterCatalog.CreateContainer(
                new CatalogLog(_log),
                typeof(MsBuildProjectContextProvider),
                typeof(IInterpreterRegistryService),
                typeof(IInterpreterOptionsService)
                ));
 }
示例#5
0
        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)));
        }
示例#6
0
 public TestExecutor()
 {
     _app                = VisualStudioProxy.FromEnvironmentVariable(PythonConstants.PythonToolsProcessIdEnvironmentVariable);
     _container          = InterpreterCatalog.CreateContainer(typeof(IInterpreterRegistryService), typeof(IInterpreterOptionsService), typeof(TestExecutorProjectContext));
     _interpreterService = _container.GetExportedValue <IInterpreterOptionsService>();
 }
示例#7
0
        private static CompositionContainer CreateCompositionContainer()
        {
            var app = VisualStudioProxy.FromEnvironmentVariable(PythonConstants.PythonToolsProcessIdEnvironmentVariable);

            return(InterpreterCatalog.CreateContainer(typeof(IInterpreterRegistryService), typeof(IInterpreterOptionsService), typeof(TestDiscoverer)));
        }