public void AssemblyLoadFromCalledWhenAssemblyNameStartsWithDollar()
		{
			IAddInTree addInTree = CreateAddInTreeWithFormsDesignerAddIn();
			DerivedRuntime runtime = new DerivedRuntime(addInTree, "$ICSharpCode.FormsDesigner/FormsDesigner.dll", String.Empty);
			runtime.Load();
			Assert.AreEqual(@"D:\SharpDevelop\AddIns\FormsDesigner\FormsDesigner.dll", runtime.AssemblyFileNamePassedToLoadAssemblyFrom);
		}
		public void Init()
		{
			// Create assembly.
			byte[] bytes = UnicodeEncoding.UTF8.GetBytesWithPreamble(GetHighlightingDefinitionXml());
			predefinedManifestResourceStream = new MemoryStream(bytes);
			assembly = new MockAssembly();
			assembly.AddManifestResourceStream("ICSharpCode.Xml.xshd", predefinedManifestResourceStream);
			
			// Create addins.
			AddIn addIn = AddIn.Load(new StringReader(GetAddInXml()));
			addIn.FileName = @"D:\SharpDevelop\AddIns\MyAddIn.addin";
			addIn.Enabled = true;
			
			List<AddIn> addIns = new List<AddIn>();
			addIns.Add(addIn);
			
			// Create runtimes.
			testRuntime = new DerivedRuntime("MyAddIn.dll", String.Empty, addIns);
			testRuntime.AssemblyFileNames.Add("MyAddIn.dll", assembly);
			
			unloadedRuntime = new DerivedRuntime("UnLoadedAssembly.dll", String.Empty, addIns);
			unloadedRuntime.AssemblyFileNames.Add("UnLoadedAssembly.dll", null);
			unloadedRuntime.LoadAssemblyFromExceptionToThrow = new FileNotFoundException("UnloadedAssembly.dll not found.");
			
			List<Runtime> runtimes = new List<Runtime>();
			runtimes.Add(testRuntime);
			runtimes.Add(unloadedRuntime);
			
			// Create addin highlighting resource.
			highlightingResource = new AddInHighlightingResource(runtimes.ToArray());
		}
 public void CoreExceptionErrorMessageShownAssemblyNameStartsWithDollarButHasNoForwardSlashCharacter()
 {
     IAddInTree addInTree = MockRepository.GenerateStrictMock<IAddInTree>();
     DerivedRuntime runtime = new DerivedRuntime(addInTree, "$ICSharpCode.FormsDesigner.dll", String.Empty);
     CoreException ex = Assert.Throws<CoreException>(delegate { runtime.Load(); });
     Assert.AreEqual("Expected '/' in path beginning with '$'!", ex.Message);
 }
示例#4
0
		public void AssemblyLoadFromCalledWhenAssemblyNameStartsWithDollar()
		{
			List<AddIn> addIns = GetAddInsList();
			DerivedRuntime runtime = new DerivedRuntime("$ICSharpCode.FormsDesigner/FormsDesigner.dll", String.Empty, addIns);
			runtime.Load();
			Assert.AreEqual(@"D:\SharpDevelop\AddIns\FormsDesigner\FormsDesigner.dll", runtime.AssemblyFileNamePassedToLoadAssemblyFrom);
		}
		public void AssemblyLoadCalledWhenAssemblyNameStartsWithColon()
		{
			IAddInTree addInTree = MockRepository.GenerateStrictMock<IAddInTree>();
			DerivedRuntime runtime = new DerivedRuntime(addInTree, ":ICSharpCode.SharpDevelop", String.Empty);
			runtime.Load();
			Assert.AreEqual("ICSharpCode.SharpDevelop", runtime.AssemblyNamePassedToLoadAssembly);
		}
		public void LoadAssemblyFromReturnsICSharpCoreTestsAssemblyForUnknownAssemblyFileName()
		{
			DerivedRuntime runtime = new DerivedRuntime("MyAddIn.dll", String.Empty);
			Assembly loadedAssembly = runtime.CallLoadAssemblyFrom("tests.dll");
			
			string expectedLoadedAssemblyName = "ICSharpCode.Core.Tests.dll";
			Assert.AreEqual(expectedLoadedAssemblyName, loadedAssembly.ManifestModule.ToString());
		}
		public void LoadAssemblyReturnsICSharpCoreTestsAssemblyForUnknownAssemblyName()
		{
			DerivedRuntime runtime = new DerivedRuntime(":ICSharpCode.SharpDevelop", String.Empty);
			Assembly loadedAssembly = runtime.CallLoadAssembly("Unknown");
			
			string expectedLoadedAssemblyName = "ICSharpCode.Core.Tests.dll";
			Assert.AreEqual(expectedLoadedAssemblyName, loadedAssembly.ManifestModule.ToString());
		}
示例#8
0
		public void RuntimeLoadedAssemblyMatchesAssemblyReturnedFromLoadAssemblyFromMethod()
		{
			DerivedRuntime runtime = new DerivedRuntime("MyAddIn.dll", @"d:\projects");
			runtime.AssemblyFileNames.Add(@"MyAddIn.dll", typeof(string).Assembly);
			Assembly loadedAssembly = runtime.LoadedAssembly;
			
			string expectedLoadedAssemblyName = "CommonLanguageRuntimeLibrary";
			Assert.AreEqual(expectedLoadedAssemblyName, loadedAssembly.ManifestModule.ToString());
		}
示例#9
0
		public void AssemblyLoadCalledWhenAssemblyNameDoesNotStartWithColonOrDollar()
		{
			string hintPath = @"D:\SharpDevelop\AddIns\FormsDesigner";
			DerivedRuntime runtime = new DerivedRuntime("FormsDesigner.dll", hintPath);
			runtime.Load();
			
			string expectedFileName = @"D:\SharpDevelop\AddIns\FormsDesigner\FormsDesigner.dll";
			Assert.AreEqual(expectedFileName, runtime.AssemblyFileNamePassedToLoadAssemblyFrom);
		}
示例#10
0
		public void RuntimeLoadedAssemblyMatchesAssemblyReturnedFromLoadAssemblyMethod()
		{
			DerivedRuntime runtime = new DerivedRuntime(":ICSharpCode.SharpDevelop", String.Empty);
			runtime.AssemblyNames.Add("ICSharpCode.SharpDevelop", typeof(string).Assembly);
			Assembly loadedAssembly = runtime.LoadedAssembly;
			
			string expectedLoadedAssemblyName = "CommonLanguageRuntimeLibrary";
			Assert.AreEqual(expectedLoadedAssemblyName, loadedAssembly.ManifestModule.ToString());
		}
		public void LoadAssemblyFromThrowsPredefinedException()
		{
			DerivedRuntime runtime = new DerivedRuntime(":ICSharpCode.SharpDevelop", String.Empty);
			ApplicationException expectedException = new ApplicationException("Test");
			runtime.LoadAssemblyFromExceptionToThrow = expectedException;
			
			ApplicationException ex = Assert.Throws<ApplicationException>(delegate { runtime.CallLoadAssemblyFrom("test"); });
			Assert.AreEqual("Test", ex.Message);
		}
		public void LoadAssemblyReturnsKnownAssemblyFromAssemblyNamesCollection()
		{
			DerivedRuntime runtime = new DerivedRuntime(":ICSharpCode.SharpDevelop", String.Empty);
			runtime.AssemblyNames.Add("ICSharpCode.SharpDevelop", typeof(string).Assembly);
			Assembly loadedAssembly = runtime.CallLoadAssembly("ICSharpCode.SharpDevelop");
			
			string expectedLoadedAssemblyName = "CommonLanguageRuntimeLibrary";
			Assert.AreEqual(expectedLoadedAssemblyName, loadedAssembly.ManifestModule.ToString());
		}
		public void LoadAssemblyFromReturnsKnownAssemblyFromAssemblyFileNamesCollection()
		{
			DerivedRuntime runtime = new DerivedRuntime("MyAddIn.dll", String.Empty);
			runtime.AssemblyFileNames.Add("MyAddIn.dll", typeof(string).Assembly);
			Assembly loadedAssembly = runtime.CallLoadAssemblyFrom(@"d:\projects\test\MyAddIn.dll");
			
			string expectedLoadedAssemblyName = "CommonLanguageRuntimeLibrary";
			Assert.AreEqual(expectedLoadedAssemblyName, loadedAssembly.ManifestModule.ToString());
		}
        public void ErrorMessageShownWhenAddInReferenceCannotBeFound()
        {
            IAddInTree addInTree = MockRepository.GenerateStrictMock<IAddInTree>();
            addInTree.Expect(a => a.AddIns).Return(new AddIn[0]);
            DerivedRuntime runtime = new DerivedRuntime(addInTree, "$UnknownAddIn/Unknown.dll", String.Empty);
            runtime.Load();

            string expectedErrorMessageStart =
                "The addin '$UnknownAddIn/Unknown.dll' could not be loaded:\n" +
                "System.IO.FileNotFoundException: Could not find referenced AddIn UnknownAddIn";
            string errorMessage = runtime.ErrorMessageDisplayed;
            Assert.IsTrue(errorMessage.StartsWith(expectedErrorMessageStart), errorMessage);
        }
		public void ErrorMessageShownWhenLoadAssemblyFromThrowsFileLoadException()
		{
			IAddInTree addInTree = MockRepository.GenerateStrictMock<IAddInTree>();
			DerivedRuntime runtime = new DerivedRuntime(addInTree, "Missing.dll", String.Empty);
			FileLoadException ex = new FileLoadException("Test");
			runtime.LoadAssemblyFromExceptionToThrow = ex;
			runtime.Load();
			
			string expectedErrorMessageStart =
				"The addin 'Missing.dll' could not be loaded:\n" +
				"System.IO.FileLoadException: Test";
			string errorMessage = runtime.ErrorMessageDisplayed;
			Assert.IsTrue(errorMessage.StartsWith(expectedErrorMessageStart), errorMessage);
		}
示例#16
0
		public void CoreExceptionErrorMessageShownAssemblyNameStartsWithDollarButHasNoForwardSlashCharacter()
		{
			List<AddIn> addIns = GetAddInsList();
			DerivedRuntime runtime = new DerivedRuntime("$ICSharpCode.FormsDesigner.dll", String.Empty, addIns);
			CoreException ex = Assert.Throws<CoreException>(delegate { runtime.Load(); });
			Assert.AreEqual("Expected '/' in path beginning with '$'!", ex.Message);
		}
示例#17
0
		public void ErrorMessageShownWhenAddInReferenceCannotBeFound()
		{
			List<AddIn> addIns = new List<AddIn>();
			DerivedRuntime runtime = new DerivedRuntime("$UnknownAddIn/Unknown.dll", String.Empty, addIns);
			runtime.Load();
			
			string expectedErrorMessageStart = 
				"The addin '$UnknownAddIn/Unknown.dll' could not be loaded:\n" +
				"System.IO.FileNotFoundException: Could not find referenced AddIn UnknownAddIn";
			string errorMessage = runtime.ErrorMessageDisplayed;
			Assert.IsTrue(errorMessage.StartsWith(expectedErrorMessageStart), errorMessage);
		}
示例#18
0
		public void ErrorMessageShownWhenLoadAssemblyFromThrowsFileLoadException()
		{
			List<AddIn> addIns = new List<AddIn>();
			DerivedRuntime runtime = new DerivedRuntime("Missing.dll", String.Empty, addIns);
			FileLoadException ex = new FileLoadException("Test");
			runtime.LoadAssemblyFromExceptionToThrow = ex;
			runtime.Load();
			
			string expectedErrorMessageStart = 
				"The addin 'Missing.dll' could not be loaded:\n" +
				"System.IO.FileLoadException: Test";
			string errorMessage = runtime.ErrorMessageDisplayed;
			Assert.IsTrue(errorMessage.StartsWith(expectedErrorMessageStart), errorMessage);
		}
示例#19
0
		public void AssemblyLoadCalledWhenAssemblyNameStartsWithColon()
		{
			DerivedRuntime runtime = new DerivedRuntime(":ICSharpCode.SharpDevelop", String.Empty);
			runtime.Load();
			Assert.AreEqual("ICSharpCode.SharpDevelop", runtime.AssemblyNamePassedToLoadAssembly);
		}