|
21 | 21 | using System.Reflection;
|
22 | 22 | using System.Text.RegularExpressions;
|
23 | 23 | using Microsoft.PythonTools.Interpreter;
|
| 24 | +using Microsoft.PythonTools.Parsing; |
24 | 25 | using Microsoft.VisualStudio.Shell.Interop;
|
25 | 26 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
26 | 27 | using TestUtilities;
|
@@ -48,49 +49,6 @@ public static void RemoveFiles() {
|
48 | 49 | }
|
49 | 50 | }
|
50 | 51 |
|
51 |
| - [TestMethod, Priority(0)] |
52 |
| - public void MinimumAssembliesLoaded() { |
53 |
| - var assembliesBefore = new HashSet<Assembly>(AppDomain.CurrentDomain.GetAssemblies()); |
54 |
| - // This assembly is probably already loaded, but let's pretend that |
55 |
| - // we've loaded it again for this test. |
56 |
| - assembliesBefore.Remove(typeof(IInterpreterOptionsService).Assembly); |
57 |
| - |
58 |
| - var catalog = new AssemblyCatalog(typeof(IInterpreterOptionsService).Assembly); |
59 |
| - var container = new CompositionContainer(catalog); |
60 |
| - var service = container.GetExportedValue<IInterpreterOptionsService>(); |
61 |
| - |
62 |
| - Assert.IsInstanceOfType(service, typeof(InterpreterOptionsService)); |
63 |
| - |
64 |
| - // Ensure these assemblies were loaded. |
65 |
| - var expectedAssemblies = new HashSet<string> { |
66 |
| - "Microsoft.PythonTools.Analysis", |
67 |
| - "Microsoft.PythonTools.VSInterpreters", |
68 |
| - "Microsoft.PythonTools.IronPython.Interpreter" |
69 |
| - }; |
70 |
| - |
71 |
| - // Ensure these assemblies were not loaded. In the out-of-VS |
72 |
| - // scenario, we cannot always resolve these and so will crash. |
73 |
| - // For tests, they are always available, and when installed they may |
74 |
| - // always be available in the GAC, but we want to ensure that they |
75 |
| - // are not loaded anyway. |
76 |
| - var notExpectedAssemblies = new HashSet<string> { |
77 |
| - "Microsoft.PythonTools", |
78 |
| - "Microsoft.VisualStudio.ReplWindow" |
79 |
| - }; |
80 |
| - |
81 |
| - Console.WriteLine("Loaded assemblies:"); |
82 |
| - foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { |
83 |
| - if (!assembliesBefore.Remove(assembly)) { |
84 |
| - var name = assembly.GetName().Name; |
85 |
| - Console.WriteLine("{0}: {1}", name, assembly.FullName); |
86 |
| - expectedAssemblies.Remove(name); |
87 |
| - Assert.IsFalse(notExpectedAssemblies.Remove(name), assembly.FullName + " should not have been loaded"); |
88 |
| - } |
89 |
| - } |
90 |
| - |
91 |
| - Assert.AreEqual(0, expectedAssemblies.Count, "Was not loaded: " + string.Join(", ", expectedAssemblies)); |
92 |
| - } |
93 |
| - |
94 | 52 | private static string CompileString(string csharpCode, string outFile) {
|
95 | 53 | var provider = new Microsoft.CSharp.CSharpCodeProvider();
|
96 | 54 | var parameters = new System.CodeDom.Compiler.CompilerParameters {
|
@@ -323,5 +281,25 @@ public void ProviderLoadLog_SuccessAndFailure() {
|
323 | 281 |
|
324 | 282 | Assert.AreEqual(1, service.KnownProviders.Count());
|
325 | 283 | }
|
| 284 | + |
| 285 | + [TestMethod, Priority(0)] |
| 286 | + public void InvalidInterpreterVersion() { |
| 287 | + try { |
| 288 | + var lv = new Version(1, 0).ToLanguageVersion(); |
| 289 | + Assert.Fail("Expected InvalidOperationException"); |
| 290 | + } catch (InvalidOperationException) { |
| 291 | + } |
| 292 | + |
| 293 | + try { |
| 294 | + InterpreterFactoryCreator.CreateInterpreterFactory(new InterpreterFactoryCreationOptions { |
| 295 | + Id = Guid.NewGuid(), |
| 296 | + LanguageVersionString = "1.0" |
| 297 | + }); |
| 298 | + Assert.Fail("Expected ArgumentException"); |
| 299 | + } catch (ArgumentException ex) { |
| 300 | + // Expect version number in message |
| 301 | + AssertUtil.Contains(ex.Message, "1.0"); |
| 302 | + } |
| 303 | + } |
326 | 304 | }
|
327 | 305 | }
|
0 commit comments