36 changed files with 1259 additions and 221 deletions
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.TextTemplating |
||||
{ |
||||
public class AddInAssemblyName |
||||
{ |
||||
string assemblyShortName; |
||||
|
||||
public AddInAssemblyName(string assemblyFullName) |
||||
{ |
||||
GetAssemblyShortName(assemblyFullName); |
||||
} |
||||
|
||||
void GetAssemblyShortName(string assemblyFullName) |
||||
{ |
||||
if (assemblyFullName != null) { |
||||
var domAssemblyName = new DomAssemblyName(assemblyFullName); |
||||
assemblyShortName = "ICSharpCode." + domAssemblyName.ShortName; |
||||
} |
||||
} |
||||
|
||||
public bool Matches(IAddIn addIn) |
||||
{ |
||||
return CompareIgnoringCase(assemblyShortName, addIn.PrimaryIdentity); |
||||
} |
||||
|
||||
bool CompareIgnoringCase(string a, string b) |
||||
{ |
||||
return String.Equals(a, b, StringComparison.OrdinalIgnoreCase); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Linq; |
||||
|
||||
namespace ICSharpCode.TextTemplating |
||||
{ |
||||
public class AddInAssemblyRuntime |
||||
{ |
||||
string fileName; |
||||
IAddIn addIn; |
||||
IAddInRuntime runtime; |
||||
|
||||
public AddInAssemblyRuntime(IAddIn addIn) |
||||
{ |
||||
this.addIn = addIn; |
||||
GetFileName(); |
||||
GetRuntime(); |
||||
} |
||||
|
||||
void GetFileName() |
||||
{ |
||||
string fileNameWithoutExtension = GetFileNameWithoutExtension(); |
||||
fileName = fileNameWithoutExtension + ".dll"; |
||||
} |
||||
|
||||
string GetFileNameWithoutExtension() |
||||
{ |
||||
string id = addIn.PrimaryIdentity; |
||||
int index = id.IndexOf(".", StringComparison.OrdinalIgnoreCase); |
||||
return id.Substring(index + 1); |
||||
} |
||||
|
||||
public string FileName { |
||||
get { return fileName; } |
||||
} |
||||
|
||||
void GetRuntime() |
||||
{ |
||||
runtime = addIn |
||||
.GetRuntimes() |
||||
.SingleOrDefault(r => Matches(r.Assembly)); |
||||
} |
||||
|
||||
public bool Matches(string runtimeFileName) |
||||
{ |
||||
return CompareIgnoringCase(runtimeFileName, this.fileName); |
||||
} |
||||
|
||||
bool CompareIgnoringCase(string a, string b) |
||||
{ |
||||
return String.Equals(a, b, StringComparison.OrdinalIgnoreCase); |
||||
} |
||||
|
||||
public IAddInRuntime Runtime { |
||||
get { return runtime; } |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Reflection; |
||||
|
||||
namespace ICSharpCode.TextTemplating |
||||
{ |
||||
public interface IAddIn |
||||
{ |
||||
string PrimaryIdentity { get; } |
||||
|
||||
IEnumerable<IAddInRuntime> GetRuntimes(); |
||||
} |
||||
} |
||||
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Reflection; |
||||
|
||||
namespace ICSharpCode.TextTemplating |
||||
{ |
||||
public interface IAddInRuntime |
||||
{ |
||||
string Assembly { get; } |
||||
Assembly LoadedAssembly { get; } |
||||
} |
||||
} |
||||
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.TextTemplating |
||||
{ |
||||
public interface IAddInTree |
||||
{ |
||||
IEnumerable<IAddIn> GetAddIns(); |
||||
} |
||||
} |
||||
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.TextTemplating |
||||
{ |
||||
public interface IAppDomain |
||||
{ |
||||
event ResolveEventHandler AssemblyResolve; |
||||
} |
||||
} |
||||
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.TextTemplating |
||||
{ |
||||
public interface ITextTemplatingAssemblyPathResolver |
||||
{ |
||||
string ResolvePath(string assemblyReference); |
||||
} |
||||
} |
||||
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.TextTemplating |
||||
{ |
||||
public interface ITextTemplatingHostAppDomainAssemblyResolver : IDisposable |
||||
{ |
||||
} |
||||
} |
||||
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Reflection; |
||||
|
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.TextTemplating |
||||
{ |
||||
public class TextTemplatingAddIn : IAddIn |
||||
{ |
||||
AddIn addIn; |
||||
|
||||
public TextTemplatingAddIn(AddIn addIn) |
||||
{ |
||||
this.addIn = addIn; |
||||
} |
||||
|
||||
public string PrimaryIdentity { |
||||
get { return this.addIn.Manifest.PrimaryIdentity; } |
||||
} |
||||
|
||||
public IEnumerable<IAddInRuntime> GetRuntimes() |
||||
{ |
||||
foreach (Runtime runtime in this.addIn.Runtimes) { |
||||
yield return new TextTemplatingAddInRuntime(runtime); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Reflection; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.TextTemplating |
||||
{ |
||||
public class TextTemplatingAddInRuntime : IAddInRuntime |
||||
{ |
||||
Runtime runtime; |
||||
|
||||
public TextTemplatingAddInRuntime(Runtime runtime) |
||||
{ |
||||
this.runtime = runtime; |
||||
} |
||||
|
||||
public string Assembly { |
||||
get { return runtime.Assembly; } |
||||
} |
||||
|
||||
public Assembly LoadedAssembly { |
||||
get { return runtime.LoadedAssembly; } |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.TextTemplating |
||||
{ |
||||
public class TextTemplatingAddInTree : IAddInTree |
||||
{ |
||||
public IEnumerable<IAddIn> GetAddIns() |
||||
{ |
||||
foreach (AddIn addIn in AddInTree.AddIns) { |
||||
yield return new TextTemplatingAddIn(addIn); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,86 @@
@@ -0,0 +1,86 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace ICSharpCode.TextTemplating |
||||
{ |
||||
public class TextTemplatingAssemblyPathResolver : ITextTemplatingAssemblyPathResolver |
||||
{ |
||||
IProject project; |
||||
IAssemblyParserService assemblyParserService; |
||||
ITextTemplatingPathResolver pathResolver; |
||||
|
||||
public TextTemplatingAssemblyPathResolver( |
||||
IProject project, |
||||
IAssemblyParserService assemblyParserService, |
||||
ITextTemplatingPathResolver pathResolver) |
||||
{ |
||||
this.project = project; |
||||
this.assemblyParserService = assemblyParserService; |
||||
this.pathResolver = pathResolver; |
||||
} |
||||
|
||||
public TextTemplatingAssemblyPathResolver(IProject project) |
||||
: this( |
||||
project, |
||||
new TextTemplatingAssemblyParserService(), |
||||
new TextTemplatingPathResolver()) |
||||
{ |
||||
} |
||||
|
||||
public string ResolvePath(string assemblyReference) |
||||
{ |
||||
assemblyReference = pathResolver.ResolvePath(assemblyReference); |
||||
if (Path.IsPathRooted(assemblyReference)) { |
||||
return assemblyReference; |
||||
} |
||||
|
||||
string resolvedAssemblyFileName = ResolveAssemblyFromProject(assemblyReference); |
||||
if (resolvedAssemblyFileName == null) { |
||||
resolvedAssemblyFileName = ResolveAssemblyFromGac(assemblyReference); |
||||
} |
||||
if (resolvedAssemblyFileName != null) { |
||||
return resolvedAssemblyFileName; |
||||
} |
||||
return assemblyReference; |
||||
} |
||||
|
||||
string ResolveAssemblyFromProject(string assemblyReference) |
||||
{ |
||||
foreach (ReferenceProjectItem refProjectItem in project.GetItemsOfType(ItemType.Reference)) { |
||||
if (IsMatch(refProjectItem, assemblyReference)) { |
||||
return refProjectItem.FileName; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
bool IsMatch(ReferenceProjectItem refProjectItem, string assemblyReference) |
||||
{ |
||||
return String.Equals(refProjectItem.Include, assemblyReference, StringComparison.InvariantCultureIgnoreCase); |
||||
} |
||||
|
||||
string ResolveAssemblyFromGac(string assemblyReference) |
||||
{ |
||||
IReflectionProjectContent projectContent = GetProjectContent(assemblyReference); |
||||
if (projectContent != null) { |
||||
return projectContent.AssemblyLocation; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
IReflectionProjectContent GetProjectContent(string assemblyReference) |
||||
{ |
||||
var reference = new ReferenceProjectItem(project, assemblyReference); |
||||
return GetProjectContent(reference); |
||||
} |
||||
|
||||
IReflectionProjectContent GetProjectContent(ReferenceProjectItem refProjectItem) |
||||
{ |
||||
return assemblyParserService.GetReflectionProjectContentForReference(refProjectItem); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,22 @@
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.TextTemplating |
||||
{ |
||||
public class TextTemplatingHostAppDomain : IAppDomain |
||||
{ |
||||
AppDomain appDomain; |
||||
|
||||
public TextTemplatingHostAppDomain() |
||||
{ |
||||
this.appDomain = AppDomain.CurrentDomain; |
||||
} |
||||
|
||||
public event ResolveEventHandler AssemblyResolve { |
||||
add { appDomain.AssemblyResolve += value; } |
||||
remove { appDomain.AssemblyResolve -= value; } |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,73 @@
@@ -0,0 +1,73 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Linq; |
||||
using System.Reflection; |
||||
|
||||
namespace ICSharpCode.TextTemplating |
||||
{ |
||||
public class TextTemplatingHostAppDomainAssemblyResolver : ITextTemplatingHostAppDomainAssemblyResolver |
||||
{ |
||||
IAppDomain hostAppDomain; |
||||
IAddInTree addInTree; |
||||
|
||||
public TextTemplatingHostAppDomainAssemblyResolver() |
||||
: this( |
||||
new TextTemplatingHostAppDomain(), |
||||
new TextTemplatingAddInTree()) |
||||
{ |
||||
} |
||||
|
||||
public TextTemplatingHostAppDomainAssemblyResolver( |
||||
IAppDomain hostAppDomain, |
||||
IAddInTree addInTree) |
||||
{ |
||||
this.hostAppDomain = hostAppDomain; |
||||
this.addInTree = addInTree; |
||||
hostAppDomain.AssemblyResolve += ResolveAssembly; |
||||
} |
||||
|
||||
Assembly ResolveAssembly(object sender, ResolveEventArgs args) |
||||
{ |
||||
var assemblyName = new AddInAssemblyName(args.Name); |
||||
return ResolveAssembly(assemblyName); |
||||
} |
||||
|
||||
Assembly ResolveAssembly(AddInAssemblyName assemblyName) |
||||
{ |
||||
IAddIn addIn = FindAddIn(assemblyName); |
||||
if (addIn != null) { |
||||
return FindAddInAssemblyFromRuntimes(addIn); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
IAddIn FindAddIn(AddInAssemblyName assemblyName) |
||||
{ |
||||
return addInTree |
||||
.GetAddIns() |
||||
.SingleOrDefault(addIn => assemblyName.Matches(addIn)); |
||||
} |
||||
|
||||
Assembly FindAddInAssemblyFromRuntimes(IAddIn addIn) |
||||
{ |
||||
IAddInRuntime runtime = FindRuntime(addIn); |
||||
if (runtime != null) { |
||||
return runtime.LoadedAssembly; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
IAddInRuntime FindRuntime(IAddIn addIn) |
||||
{ |
||||
var addinRuntime = new AddInAssemblyRuntime(addIn); |
||||
return addinRuntime.Runtime; |
||||
} |
||||
|
||||
public void Dispose() |
||||
{ |
||||
hostAppDomain.AssemblyResolve -= ResolveAssembly; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Reflection; |
||||
using ICSharpCode.TextTemplating; |
||||
|
||||
namespace TextTemplating.Tests.Helpers |
||||
{ |
||||
public class FakeAddIn : IAddIn |
||||
{ |
||||
public FakeAddIn() |
||||
: this(String.Empty) |
||||
{ |
||||
} |
||||
|
||||
public FakeAddIn(string id) |
||||
{ |
||||
this.PrimaryIdentity = id; |
||||
} |
||||
|
||||
public string PrimaryIdentity { get; set; } |
||||
|
||||
public List<FakeAddInRuntime> FakeAddInRuntimes = new List<FakeAddInRuntime>(); |
||||
|
||||
public IEnumerable<IAddInRuntime> GetRuntimes() |
||||
{ |
||||
return FakeAddInRuntimes; |
||||
} |
||||
|
||||
public FakeAddInRuntime AddFakeAddInRuntime(string assemblyFileName) |
||||
{ |
||||
return AddFakeAddInRuntime(assemblyFileName, null); |
||||
} |
||||
|
||||
public FakeAddInRuntime AddFakeAddInRuntime(string assemblyFileName, Assembly loadedAssembly) |
||||
{ |
||||
var runtime = new FakeAddInRuntime(assemblyFileName, loadedAssembly); |
||||
FakeAddInRuntimes.Add(runtime); |
||||
return runtime; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Reflection; |
||||
using ICSharpCode.TextTemplating; |
||||
|
||||
namespace TextTemplating.Tests.Helpers |
||||
{ |
||||
public class FakeAddInRuntime : IAddInRuntime |
||||
{ |
||||
public FakeAddInRuntime(string assembly, Assembly loadedAssembly) |
||||
{ |
||||
this.Assembly = assembly; |
||||
this.LoadedAssembly = loadedAssembly; |
||||
} |
||||
|
||||
public string Assembly { get; set; } |
||||
public Assembly LoadedAssembly { get; set; } |
||||
} |
||||
} |
||||
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Reflection; |
||||
|
||||
using ICSharpCode.TextTemplating; |
||||
|
||||
namespace TextTemplating.Tests.Helpers |
||||
{ |
||||
public class FakeAddInTree : IAddInTree |
||||
{ |
||||
List<FakeAddIn> FakeAddIns = new List<FakeAddIn>(); |
||||
|
||||
public FakeAddIn AddFakeAddIn(string id) |
||||
{ |
||||
var fakeAddIn = new FakeAddIn(id); |
||||
FakeAddIns.Add(fakeAddIn); |
||||
return fakeAddIn; |
||||
} |
||||
|
||||
public IEnumerable<IAddIn> GetAddIns() |
||||
{ |
||||
return FakeAddIns; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Reflection; |
||||
using ICSharpCode.TextTemplating; |
||||
|
||||
namespace TextTemplating.Tests.Helpers |
||||
{ |
||||
public class FakeAppDomain : IAppDomain |
||||
{ |
||||
public event ResolveEventHandler AssemblyResolve; |
||||
|
||||
public Assembly FireAssemblyResolveEvent(string assemblyName) |
||||
{ |
||||
var eventArgs = new ResolveEventArgs(assemblyName); |
||||
return FireAssemblyResolveEvent(eventArgs); |
||||
} |
||||
|
||||
public Assembly FireAssemblyResolveEvent(ResolveEventArgs e) |
||||
{ |
||||
if (AssemblyResolve != null) { |
||||
return AssemblyResolve(this, e); |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.TextTemplating; |
||||
|
||||
namespace TextTemplating.Tests.Helpers |
||||
{ |
||||
public class FakeTextTemplatingAssemblyPathResolver : ITextTemplatingAssemblyPathResolver |
||||
{ |
||||
public string AssemblyReferencePassedToResolvePath; |
||||
public string ResolvePathReturnValue; |
||||
|
||||
public string ResolvePath(string assemblyReference) |
||||
{ |
||||
AssemblyReferencePassedToResolvePath = assemblyReference; |
||||
return ResolvePathReturnValue; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.TextTemplating; |
||||
|
||||
namespace TextTemplating.Tests.Helpers |
||||
{ |
||||
public class FakeTextTemplatingHostAppDomainAssemblyResolver : ITextTemplatingHostAppDomainAssemblyResolver |
||||
{ |
||||
public bool IsDisposeCalled; |
||||
|
||||
public void Dispose() |
||||
{ |
||||
IsDisposeCalled = true; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.TextTemplating; |
||||
using NUnit.Framework; |
||||
|
||||
namespace TextTemplating.Tests.Helpers |
||||
{ |
||||
[TestFixture] |
||||
public class TextTemplatingHostContextTests |
||||
{ |
||||
TextTemplatingHostContext hostContext; |
||||
FakeTextTemplatingAssemblyResolver fakeAssemblyResolver; |
||||
|
||||
void CreateHostContext() |
||||
{ |
||||
var testableHost = new TestableTextTemplatingHost("Test"); |
||||
hostContext = testableHost.HostContext; |
||||
fakeAssemblyResolver = testableHost.FakeTextTemplatingAssemblyResolver; |
||||
} |
||||
|
||||
[Test] |
||||
public void Dispose_DisposeCalled_DisposesAssemblyResolver() |
||||
{ |
||||
CreateHostContext(); |
||||
hostContext.Dispose(); |
||||
|
||||
Assert.IsTrue(fakeAssemblyResolver.IsDisposeCalled); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,81 @@
@@ -0,0 +1,81 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.TextTemplating; |
||||
using NUnit.Framework; |
||||
using TextTemplating.Tests.Helpers; |
||||
|
||||
namespace TextTemplating.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class AddInAssemblyNameTests |
||||
{ |
||||
AddInAssemblyName addInAssemblyName; |
||||
|
||||
void CreateAssemblyName(string assemblyName) |
||||
{ |
||||
addInAssemblyName = new AddInAssemblyName(assemblyName); |
||||
} |
||||
|
||||
FakeAddIn CreateFakeAddIn(string id) |
||||
{ |
||||
return new FakeAddIn(id); |
||||
} |
||||
|
||||
[Test] |
||||
public void Matches_AssemblyNameIsPackageManagementAndAddInIsICSharpCodePackageManagement_ReturnsTrue() |
||||
{ |
||||
CreateAssemblyName("PackageManagement, Version=4.0, Culture=neutral, PublicKeyToken=null"); |
||||
FakeAddIn addIn = CreateFakeAddIn("ICSharpCode.PackageManagement"); |
||||
|
||||
bool matches = addInAssemblyName.Matches(addIn); |
||||
|
||||
Assert.IsTrue(matches); |
||||
} |
||||
|
||||
[Test] |
||||
public void Matches_AssemblyNameIsTestAndAddInIsICSharpCodePackageManagement_ReturnsFalse() |
||||
{ |
||||
CreateAssemblyName("Test, Version=4.0, Culture=neutral, PublicKeyToken=null"); |
||||
FakeAddIn addIn = CreateFakeAddIn("ICSharpCode.PackageManagement"); |
||||
|
||||
bool matches = addInAssemblyName.Matches(addIn); |
||||
|
||||
Assert.IsFalse(matches); |
||||
} |
||||
|
||||
[Test] |
||||
public void Matches_AssemblyNameIsPackageManagementAndAddInIsICSharpCodePackageManagementInDifferentCase_ReturnsTrue() |
||||
{ |
||||
CreateAssemblyName("PackageManagement, Version=4.0, Culture=neutral, PublicKeyToken=null"); |
||||
FakeAddIn addIn = CreateFakeAddIn("icsharpcode.packagemanagement"); |
||||
|
||||
bool matches = addInAssemblyName.Matches(addIn); |
||||
|
||||
Assert.IsTrue(matches); |
||||
} |
||||
|
||||
[Test] |
||||
public void Matches_NullAddInPrimaryIdentifier_ReturnsFalse() |
||||
{ |
||||
CreateAssemblyName("Test, Version=1.0"); |
||||
FakeAddIn addIn = CreateFakeAddIn(null); |
||||
|
||||
bool matches = addInAssemblyName.Matches(addIn); |
||||
|
||||
Assert.IsFalse(matches); |
||||
} |
||||
|
||||
[Test] |
||||
public void Matches_NullAssemblyName_ReturnsFalse() |
||||
{ |
||||
CreateAssemblyName(null); |
||||
FakeAddIn addIn = CreateFakeAddIn("Test"); |
||||
|
||||
bool matches = addInAssemblyName.Matches(addIn); |
||||
|
||||
Assert.IsFalse(matches); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,130 @@
@@ -0,0 +1,130 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.TextTemplating; |
||||
using NUnit.Framework; |
||||
using TextTemplating.Tests.Helpers; |
||||
|
||||
namespace TextTemplating.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class AddInAssemblyRuntimeTests |
||||
{ |
||||
AddInAssemblyRuntime runtime; |
||||
|
||||
void CreateRuntime(string id) |
||||
{ |
||||
var fakeAddIn = CreateFakeAddIn(id); |
||||
CreateRuntime(fakeAddIn); |
||||
} |
||||
|
||||
FakeAddIn CreateFakeAddIn(string id) |
||||
{ |
||||
return new FakeAddIn(id); |
||||
} |
||||
|
||||
void CreateRuntime(FakeAddIn fakeAddIn) |
||||
{ |
||||
runtime = new AddInAssemblyRuntime(fakeAddIn); |
||||
} |
||||
|
||||
[Test] |
||||
public void FileName_AddInIdIsICSharpCodePackageManagement_ReturnsPackageManagementDll() |
||||
{ |
||||
CreateRuntime("ICSharpCode.PackageManagement"); |
||||
|
||||
string fileName = runtime.FileName; |
||||
|
||||
Assert.AreEqual("PackageManagement.dll", fileName); |
||||
} |
||||
|
||||
[Test] |
||||
public void FileName_AddInIdIsICSharpCodePackageManagementInLowerCase_ReturnsPackageManagementDll() |
||||
{ |
||||
CreateRuntime("icsharpcode.packageManagement"); |
||||
|
||||
string fileName = runtime.FileName; |
||||
|
||||
Assert.AreEqual("packageManagement.dll", fileName); |
||||
} |
||||
|
||||
[Test] |
||||
public void FileName_AddInIdIsMyAddIn_ReturnsMyAddInDll() |
||||
{ |
||||
CreateRuntime("MyAddIn"); |
||||
|
||||
string fileName = runtime.FileName; |
||||
|
||||
Assert.AreEqual("MyAddIn.dll", fileName); |
||||
} |
||||
|
||||
[Test] |
||||
public void Matches_FileNameMatchesAddInRuntimeFileName_ReturnsTrue() |
||||
{ |
||||
CreateRuntime("ICSharpCode.PackageManagement"); |
||||
|
||||
bool match = runtime.Matches("PackageManagement.dll"); |
||||
|
||||
Assert.IsTrue(match); |
||||
} |
||||
|
||||
[Test] |
||||
public void Matches_FileNameDoesNotMatchAddInRuntimeFileName_ReturnsFalse() |
||||
{ |
||||
CreateRuntime("ICSharpCode.PackageManagement"); |
||||
|
||||
bool match = runtime.Matches("test.dll"); |
||||
|
||||
Assert.IsFalse(match); |
||||
} |
||||
|
||||
[Test] |
||||
public void Matches_FileNameInDifferentCaseToAddInRuntimeFileName_ReturnsTrue() |
||||
{ |
||||
CreateRuntime("ICSharpCode.PackageManagement"); |
||||
|
||||
bool match = runtime.Matches("packagemanagement.dll"); |
||||
|
||||
Assert.IsTrue(match); |
||||
} |
||||
|
||||
[Test] |
||||
public void Runtime_AddInHasMatchingAddInRuntime_ReturnsAddInRuntime() |
||||
{ |
||||
FakeAddIn fakeAddIn = CreateFakeAddIn("ICSharpCode.PackageManagement"); |
||||
FakeAddInRuntime expectedRuntime = fakeAddIn.AddFakeAddInRuntime("PackageManagement.dll"); |
||||
CreateRuntime(fakeAddIn); |
||||
|
||||
IAddInRuntime addInRuntime = runtime.Runtime; |
||||
|
||||
Assert.AreEqual(expectedRuntime, addInRuntime); |
||||
} |
||||
|
||||
[Test] |
||||
public void Runtime_AddInHasThreeRuntimesWithSecondOneMatchingAddInRuntime_ReturnsSecondAddInRuntime() |
||||
{ |
||||
FakeAddIn fakeAddIn = CreateFakeAddIn("ICSharpCode.PackageManagement"); |
||||
fakeAddIn.AddFakeAddInRuntime("Test.dll"); |
||||
FakeAddInRuntime expectedRuntime = fakeAddIn.AddFakeAddInRuntime("PackageManagement.dll"); |
||||
fakeAddIn.AddFakeAddInRuntime("AnotherTest.dll"); |
||||
CreateRuntime(fakeAddIn); |
||||
|
||||
IAddInRuntime addInRuntime = runtime.Runtime; |
||||
|
||||
Assert.AreEqual(expectedRuntime, addInRuntime); |
||||
} |
||||
|
||||
[Test] |
||||
public void Runtime_AddInHasMatchingAddInRuntimeButWthDifferentCase_ReturnsAddInRuntime() |
||||
{ |
||||
FakeAddIn fakeAddIn = CreateFakeAddIn("ICSharpCode.PackageManagement"); |
||||
FakeAddInRuntime expectedRuntime = fakeAddIn.AddFakeAddInRuntime("packageManagement.dll"); |
||||
CreateRuntime(fakeAddIn); |
||||
|
||||
IAddInRuntime addInRuntime = runtime.Runtime; |
||||
|
||||
Assert.AreEqual(expectedRuntime, addInRuntime); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,178 @@
@@ -0,0 +1,178 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Internal.Templates; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.TextTemplating; |
||||
using NUnit.Framework; |
||||
using TextTemplating.Tests.Helpers; |
||||
|
||||
namespace TextTemplating.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class TextTemplatingAssemblyPathResolverTests |
||||
{ |
||||
TextTemplatingAssemblyPathResolver resolver; |
||||
IProject project; |
||||
FakeAssemblyParserService fakeAssemblyParserService; |
||||
FakeTextTemplatingPathResolver fakePathResolver; |
||||
|
||||
void CreateResolver() |
||||
{ |
||||
project = ProjectHelper.CreateProject(); |
||||
fakeAssemblyParserService = new FakeAssemblyParserService(); |
||||
fakePathResolver = new FakeTextTemplatingPathResolver(); |
||||
resolver = new TextTemplatingAssemblyPathResolver(project, fakeAssemblyParserService, fakePathResolver); |
||||
} |
||||
|
||||
ReferenceProjectItem AddReferenceToProject(string referenceName) |
||||
{ |
||||
ReferenceProjectItem projectItem = new ReferenceProjectItem(project, referenceName); |
||||
ProjectService.AddProjectItem(project, projectItem); |
||||
return projectItem; |
||||
} |
||||
|
||||
IProject GetProjectPassedToAssemblyParserService() |
||||
{ |
||||
return ReferenceProjectItemPassedToGetReflectionProjectContentForReference.Project; |
||||
} |
||||
|
||||
ReferenceProjectItem ReferenceProjectItemPassedToGetReflectionProjectContentForReference { |
||||
get { return fakeAssemblyParserService.ItemPassedToGetReflectionProjectContentForReference; } |
||||
} |
||||
|
||||
ItemType GetReferenceItemTypePassedToAssemblyParserService() |
||||
{ |
||||
return ReferenceProjectItemPassedToGetReflectionProjectContentForReference.ItemType; |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolvePath_ProjectHasNoReferences_ReturnsAssemblyReferencePassedToMethod() |
||||
{ |
||||
CreateResolver(); |
||||
fakeAssemblyParserService.FakeReflectionProjectContent = null; |
||||
string result = resolver.ResolvePath("Test"); |
||||
|
||||
Assert.AreEqual("Test", result); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolvePath_ProjectHasOneReferenceToTestAssemblyWithHintPathSet_ReturnsFullPathToTestAssembly() |
||||
{ |
||||
CreateResolver(); |
||||
ReferenceProjectItem reference = AddReferenceToProject("test"); |
||||
string expectedFileName = @"d:\projects\MyProject\lib\Test.dll"; |
||||
reference.HintPath = expectedFileName; |
||||
|
||||
string result = resolver.ResolvePath("Test"); |
||||
|
||||
Assert.AreEqual(expectedFileName, result); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolvePath_AssemblyReferenceNameIsInDifferentCase_ReturnsFullPathToTestAssembly() |
||||
{ |
||||
CreateResolver(); |
||||
ReferenceProjectItem reference = AddReferenceToProject("test"); |
||||
string expectedFileName = @"d:\projects\MyProject\lib\Test.dll"; |
||||
reference.HintPath = expectedFileName; |
||||
|
||||
string result = resolver.ResolvePath("TEST"); |
||||
|
||||
Assert.AreEqual(expectedFileName, result); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolvePath_ProjectHasOneReferenceToTestAssemblyWithFileNameSet_ReturnsFullPathToTestAssembly() |
||||
{ |
||||
CreateResolver(); |
||||
ReferenceProjectItem reference = AddReferenceToProject("Test"); |
||||
string expectedFileName = @"d:\projects\MyProject\lib\Test.dll"; |
||||
reference.FileName = expectedFileName; |
||||
|
||||
string result = resolver.ResolvePath("Test"); |
||||
|
||||
Assert.AreEqual(expectedFileName, result); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolvePath_ProjectHasNoReferencesAndAssemblyReferenceInGac_ReturnsFullPathToAssemblyFoundFromAssemblyParserService() |
||||
{ |
||||
CreateResolver(); |
||||
string expectedFileName = @"c:\Windows\System32\Gac\System.Data.dll"; |
||||
fakeAssemblyParserService.FakeReflectionProjectContent.AssemblyLocation = expectedFileName; |
||||
|
||||
string result = resolver.ResolvePath("System.Data"); |
||||
|
||||
Assert.AreEqual(expectedFileName, result); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolvePath_ProjectHasNoReferencesAndAssemblyReferenceInGac_ReferenceItemPassedToAssemblyParserServiceUsesProject() |
||||
{ |
||||
CreateResolver(); |
||||
string result = resolver.ResolvePath("System.Data"); |
||||
IProject expectedProject = GetProjectPassedToAssemblyParserService(); |
||||
|
||||
Assert.AreEqual(project, expectedProject); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolvePath_ProjectHasNoReferencesAndAssemblyReferenceInGac_ReferenceItemPassedToAssemblyParserServiceIsReference() |
||||
{ |
||||
CreateResolver(); |
||||
string result = resolver.ResolvePath("System.Data"); |
||||
ItemType type = GetReferenceItemTypePassedToAssemblyParserService(); |
||||
|
||||
Assert.AreEqual(ItemType.Reference, type); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolvePath_ProjectHasNoReferencesAndAssemblyReferenceInGac_ReferenceItemIncludePassedToAssemblyParserServiceIsAssemblyNameToResolvePath() |
||||
{ |
||||
CreateResolver(); |
||||
string result = resolver.ResolvePath("System.Data"); |
||||
string referenceInclude = ReferenceProjectItemPassedToGetReflectionProjectContentForReference.Include; |
||||
|
||||
Assert.AreEqual("System.Data", referenceInclude); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolvePath_ProjectHasNoReferencesAndAssemblyReferenceNotFoundInGac_ReturnsAssemblyReferencePassedToMethod() |
||||
{ |
||||
CreateResolver(); |
||||
fakeAssemblyParserService.FakeReflectionProjectContent = null; |
||||
|
||||
string result = resolver.ResolvePath("System.Data"); |
||||
|
||||
Assert.AreEqual("System.Data", result); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolvePath_AssemblyReferenceHasTemplateVariable_ReturnsExpandedAssemblyReferenceFileName() |
||||
{ |
||||
CreateResolver(); |
||||
string path = @"$(SolutionDir)lib\Test.dll"; |
||||
string expectedPath = @"d:\projects\MyProject\lib\Test.dll"; |
||||
fakePathResolver.AddPath(path, expectedPath); |
||||
|
||||
string resolvedPath = resolver.ResolvePath(path); |
||||
|
||||
Assert.AreEqual(expectedPath, resolvedPath); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolvePath_AssemblyReferenceHasTemplateVariable_AssemblyParserServiceIsNotUsed() |
||||
{ |
||||
CreateResolver(); |
||||
string path = @"$(SolutionDir)lib\Test.dll"; |
||||
string expectedPath = @"d:\projects\MyProject\lib\Test.dll"; |
||||
fakePathResolver.AddPath(path, expectedPath); |
||||
|
||||
string result = resolver.ResolvePath(path); |
||||
|
||||
Assert.IsFalse(fakeAssemblyParserService.IsGetReflectionProjectContentForReferenceCalled); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,144 @@
@@ -0,0 +1,144 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Reflection; |
||||
using ICSharpCode.TextTemplating; |
||||
using NUnit.Framework; |
||||
using TextTemplating.Tests.Helpers; |
||||
|
||||
namespace TextTemplating.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class TextTemplatingHostAppDomainAssemblyResolverTests |
||||
{ |
||||
TextTemplatingHostAppDomainAssemblyResolver resolver; |
||||
FakeAppDomain fakeAppDomain; |
||||
FakeAddInTree fakeAddInTree; |
||||
|
||||
void CreateResolver() |
||||
{ |
||||
fakeAppDomain = new FakeAppDomain(); |
||||
fakeAddInTree = new FakeAddInTree(); |
||||
resolver = new TextTemplatingHostAppDomainAssemblyResolver(fakeAppDomain, fakeAddInTree); |
||||
} |
||||
|
||||
FakeAddIn AddFakeAddInToTree(string id) |
||||
{ |
||||
return fakeAddInTree.AddFakeAddIn(id); |
||||
} |
||||
|
||||
void AddFakeRuntime(FakeAddIn fakeAddIn, string runtimeFileName) |
||||
{ |
||||
AddFakeRuntime(fakeAddIn, runtimeFileName, null); |
||||
} |
||||
|
||||
void AddFakeRuntime(FakeAddIn fakeAddIn, string runtimeFileName, Assembly assembly) |
||||
{ |
||||
fakeAddIn.AddFakeAddInRuntime(runtimeFileName, assembly); |
||||
} |
||||
|
||||
[Test] |
||||
public void AssemblyResolve_EventFiredForAssemblyThatMatchesAddInAssembly_ReturnsAddInAssembly() |
||||
{ |
||||
CreateResolver(); |
||||
FakeAddIn fakeAddIn = AddFakeAddInToTree("ICSharpCode.PackageManagement"); |
||||
Assembly expectedAssembly = typeof(string).Assembly; |
||||
AddFakeRuntime(fakeAddIn, "PackageManagement.dll", expectedAssembly); |
||||
|
||||
string assemblyName = "PackageManagement, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null"; |
||||
Assembly assembly = fakeAppDomain.FireAssemblyResolveEvent(assemblyName); |
||||
|
||||
Assert.AreEqual(expectedAssembly, assembly); |
||||
} |
||||
|
||||
|
||||
|
||||
[Test] |
||||
public void Dispose_EventFiredForAssemblyThatMatchesAddInAssemblyAfter_DoesNotReturnAddInAssembly() |
||||
{ |
||||
CreateResolver(); |
||||
FakeAddIn fakeAddIn = AddFakeAddInToTree("ICSharpCode.PackageManagement"); |
||||
Assembly expectedAssembly = typeof(string).Assembly; |
||||
AddFakeRuntime(fakeAddIn, "PackageManagement.dll", expectedAssembly); |
||||
|
||||
resolver.Dispose(); |
||||
|
||||
string assemblyName = "PackageManagement, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null"; |
||||
Assembly assembly = fakeAppDomain.FireAssemblyResolveEvent(assemblyName); |
||||
|
||||
Assert.IsNull(assembly); |
||||
} |
||||
|
||||
[Test] |
||||
public void AssemblyResolve_EventFiredForAssemblyThatMatchesSecondAddInAssembly_ReturnsSecondAddInAssembly() |
||||
{ |
||||
CreateResolver(); |
||||
AddFakeAddInToTree("ICSharpCode.Test"); |
||||
FakeAddIn fakeAddIn = AddFakeAddInToTree("ICSharpCode.PackageManagement"); |
||||
Assembly expectedAssembly = this.GetType().Assembly; |
||||
AddFakeRuntime(fakeAddIn, "PackageManagement.dll", expectedAssembly); |
||||
|
||||
string assemblyName = "PackageManagement, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null"; |
||||
Assembly assembly = fakeAppDomain.FireAssemblyResolveEvent(assemblyName); |
||||
|
||||
Assert.AreEqual(expectedAssembly, assembly); |
||||
} |
||||
|
||||
[Test] |
||||
public void AssemblyResolve_EventFiredForAssemblyThatMatchesFirstOutOfTwoAddInAssemblies_ReturnsFirstAddInAssembly() |
||||
{ |
||||
CreateResolver(); |
||||
FakeAddIn fakeAddIn = AddFakeAddInToTree("ICSharpCode.PackageManagement"); |
||||
Assembly expectedAssembly = this.GetType().Assembly; |
||||
AddFakeRuntime(fakeAddIn, "PackageManagement.dll", expectedAssembly); |
||||
|
||||
AddFakeAddInToTree("ICSharpCode.Test"); |
||||
|
||||
string assemblyName = "PackageManagement, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null"; |
||||
Assembly assembly = fakeAppDomain.FireAssemblyResolveEvent(assemblyName); |
||||
|
||||
Assert.AreEqual(expectedAssembly, assembly); |
||||
} |
||||
|
||||
[Test] |
||||
public void AssemblyResolve_EventFiredForAssemblyThatDoesNotMatchAnyAddIns_ReturnsNull() |
||||
{ |
||||
CreateResolver(); |
||||
AddFakeAddInToTree("ICSharpCode.Test"); |
||||
|
||||
string assemblyName = "Unknown, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null"; |
||||
Assembly assembly = fakeAppDomain.FireAssemblyResolveEvent(assemblyName); |
||||
|
||||
Assert.IsNull(assembly); |
||||
} |
||||
|
||||
[Test] |
||||
public void AssemblyResolve_MatchedAddInHasNoRuntimes_ReturnsNull() |
||||
{ |
||||
CreateResolver(); |
||||
AddFakeAddInToTree("ICSharpCode.Test"); |
||||
|
||||
string assemblyName = "Test, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null"; |
||||
Assembly assembly = fakeAppDomain.FireAssemblyResolveEvent(assemblyName); |
||||
|
||||
Assert.IsNull(assembly); |
||||
} |
||||
|
||||
[Test] |
||||
public void AssemblyResolve_AddInAssemblyIsSecondOfThreeRuntimes_ReturnsAddInAssemblyFromSecondRuntime() |
||||
{ |
||||
CreateResolver(); |
||||
FakeAddIn fakeAddIn = AddFakeAddInToTree("ICSharpCode.PackageManagement"); |
||||
AddFakeRuntime(fakeAddIn, ":ICSharpCode.SharpDevelop"); |
||||
Assembly expectedAssembly = this.GetType().Assembly; |
||||
AddFakeRuntime(fakeAddIn, "PackageManagement.dll", expectedAssembly); |
||||
AddFakeRuntime(fakeAddIn, "IronPython.dll"); |
||||
|
||||
string assemblyName = "PackageManagement, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null"; |
||||
Assembly assembly = fakeAppDomain.FireAssemblyResolveEvent(assemblyName); |
||||
|
||||
Assert.AreEqual(expectedAssembly, assembly); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue