public void ProviderLoadLog_SuccessAndFailure() { var sp = new MockServiceProvider(); var log = new MockActivityLog(); sp.Services[typeof(SVsActivityLog).GUID] = log; var sm = new MockSettingsManager(); sp.Services[typeof(SVsSettingsManager).GUID] = sm; var path1 = FactoryProviderTypeLoadErrorPath; var path2 = FactoryProviderSuccessPath; sm.Store.AddSetting(@"PythonTools\InterpreterFactories\Test1", "CodeBase", path1); sm.Store.AddSetting(@"PythonTools\InterpreterFactories\Test2", "CodeBase", path2); var service = new InterpreterOptionsService(sp); foreach (var msg in log.AllItems) { Console.WriteLine(msg); } AssertUtil.AreEqual( new Regex(@"Error//Python Tools//Failed to import factory providers.*System\.ComponentModel\.Composition\.CompositionException"), log.ErrorsAndWarnings.Single() ); Assert.AreEqual(1, service.KnownProviders.Count()); }
public void ProviderLoadLog_FileNotFound() { var sp = new MockServiceProvider(); var log = new MockActivityLog(); sp.Services[typeof(SVsActivityLog).GUID] = log; var sm = new MockSettingsManager(); sp.Services[typeof(SVsSettingsManager).GUID] = sm; var path = Path.ChangeExtension(Path.GetTempFileName(), "dll"); File.Delete(path); Assert.IsFalse(File.Exists(path)); sm.Store.AddSetting(@"PythonTools\InterpreterFactories\Test", "CodeBase", path); var service = new InterpreterOptionsService(sp); foreach (var msg in log.AllItems) { Console.WriteLine(msg); } AssertUtil.AreEqual( new Regex(@"Error//Python Tools//Failed to load interpreter provider assembly.+System\.IO\.FileNotFoundException.+//" + Regex.Escape(path)), log.ErrorsAndWarnings.Single() ); }
public void ProviderLoadLog_CorruptImage() { var sp = new MockServiceProvider(); var log = new MockActivityLog(); sp.Services[typeof(SVsActivityLog).GUID] = log; var sm = new MockSettingsManager(); sp.Services[typeof(SVsSettingsManager).GUID] = sm; var path = FactoryProviderCorruptPath; sm.Store.AddSetting(@"PythonTools\InterpreterFactories\Test", "CodeBase", path); var service = new InterpreterOptionsService(sp); foreach (var msg in log.AllItems) { Console.WriteLine(msg); } AssertUtil.AreEqual( new Regex(@"Error//Python Tools//Failed to load interpreter provider assembly.+System\.BadImageFormatException.+//" + Regex.Escape(path)), log.ErrorsAndWarnings.Single() ); }
public void ProviderLoadLog_Success() { var sp = new MockServiceProvider(); var log = new MockActivityLog(); sp.Services[typeof(SVsActivityLog).GUID] = log; var sm = new MockSettingsManager(); sp.Services[typeof(SVsSettingsManager).GUID] = sm; var path = FactoryProviderSuccessPath; sm.Store.AddSetting(@"PythonTools\InterpreterFactories\Test", "CodeBase", path); var service = new InterpreterOptionsService(sp); foreach (var msg in log.AllItems) { Console.WriteLine(msg); } AssertUtil.AreEqual( new Regex(@"Information//Python Tools//Loading interpreter provider assembly.*//" + Regex.Escape(path)), log.AllItems.Single() ); Assert.AreEqual(1, service.KnownProviders.Count()); }