67 changed files with 1465 additions and 172 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,18 +1,25 @@ |
|||||||
<?xml version="1.0"?> |
<?xml version="1.0"?> |
||||||
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
||||||
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> |
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> |
||||||
<id>AvalonEdit</id> |
<id>AvalonEdit</id> |
||||||
<version>4.0.0.7070</version> |
<version>4.1.0.8000</version> |
||||||
<authors>Daniel Grunwald</authors> |
<authors>Daniel Grunwald</authors> |
||||||
<owners>SharpDevelop</owners> |
<owners>SharpDevelop</owners> |
||||||
<licenseUrl>http://www.opensource.org/licenses/lgpl-2.1.php</licenseUrl> |
<licenseUrl>http://www.opensource.org/licenses/lgpl-2.1.php</licenseUrl> |
||||||
<projectUrl>http://www.avalonedit.net</projectUrl> |
<projectUrl>http://www.avalonedit.net</projectUrl> |
||||||
<iconUrl>http://community.sharpdevelop.net/blogs/mattward/SharpDevelop.png</iconUrl> |
<iconUrl>http://community.sharpdevelop.net/blogs/mattward/SharpDevelop.png</iconUrl> |
||||||
<requireLicenseAcceptance>true</requireLicenseAcceptance> |
<requireLicenseAcceptance>true</requireLicenseAcceptance> |
||||||
<description>AvalonEdit is the WPF-based text editor used in SharpDevelop 4.0. |
<description>AvalonEdit is the WPF-based text editor used in SharpDevelop. There are two builds of AvalonEdit included in this package. One that targets .NET 4.0 and one that targets .NET 3.5.</description> |
||||||
There are two builds of AvalonEdit included in this package. One that targets .NET 4.0 and |
<summary>AvalonEdit is the WPF-based text editor used in SharpDevelop</summary> |
||||||
one that targets .NET 3.5.</description> |
<releaseNotes>Improved WPF text rendering performance. |
||||||
<summary>AvalonEdit is the WPF-based text editor used in SharpDevelop 4.0.</summary> |
Region tooltips added. |
||||||
<language>en-US</language> |
C# syntax highlighting: Do not colorize punctuation.</releaseNotes> |
||||||
|
<language>en-US</language> |
||||||
|
<tags>WPF Text Editor SharpDevelop AvalonEdit</tags> |
||||||
</metadata> |
</metadata> |
||||||
|
<files> |
||||||
|
<file src="lib\Net35\*.*" target="lib\Net35" /> |
||||||
|
<file src="lib\Net40\*.*" target="lib\Net40" /> |
||||||
|
<file src="..\..\..\..\..\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\**\*.cs" target="src" /> |
||||||
|
</files> |
||||||
</package> |
</package> |
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,4 +1,21 @@ |
|||||||
nuget.exe pack AvalonEdit\AvalonEdit.nuspec -b AvalonEdit -o AvalonEdit |
@ECHO OFF |
||||||
nuget.exe pack AvalonEdit.Sample\AvalonEdit.Sample.nuspec -b AvalonEdit.Sample -o AvalonEdit.Sample |
SETLOCAL |
||||||
nuget.exe pack ICSharpCode.TextEditor\ICSharpCode.TextEditor.nuspec -b ICSharpCode.TextEditor -o ICSharpCode.TextEditor |
SET msbuild=%windir%\microsoft.net\framework\v4.0.30319\msbuild |
||||||
nuget.exe pack ICSharpCode.TextEditor.Sample\ICSharpCode.TextEditor.Sample.nuspec -b ICSharpCode.TextEditor.Sample -o ICSharpCode.TextEditor.Sample |
SET project=..\..\..\..\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj |
||||||
|
SET buildoptions=/t:Rebuild /p:Configuration=Release /p:DebugType=PdbOnly |
||||||
|
|
||||||
|
@ECHO ON |
||||||
|
:Clean debug build |
||||||
|
%msbuild% /m %project% /t:Clean /p:Configuration=Debug /p:OutputPath=%~dp0\AvalonEdit\lib\Net40 |
||||||
|
|
||||||
|
:BUILD .NET 4.0 version |
||||||
|
%msbuild% /m %project% %buildoptions% /p:OutputPath=%~dp0\AvalonEdit\lib\Net40 |
||||||
|
|
||||||
|
:BUILD .NET 3.5 version |
||||||
|
%msbuild% /m %project% %buildoptions% "/p:DefineConstants=TRACE" "/p:TargetFrameworkVersion=v3.5" /p:OutputPath=%~dp0\AvalonEdit\lib\Net35 |
||||||
|
|
||||||
|
nuget.exe pack AvalonEdit\AvalonEdit.nuspec -Symbols -BasePath AvalonEdit -OutputDirectory AvalonEdit |
||||||
|
nuget.exe pack AvalonEdit.Sample\AvalonEdit.Sample.nuspec -BasePath AvalonEdit.Sample -OutputDirectory AvalonEdit.Sample |
||||||
|
|
||||||
|
@ECHO OFF |
||||||
|
ENDLOCAL |
||||||
@ -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 ITextTemplatingEnvironment |
||||||
|
{ |
||||||
|
string ExpandEnvironmentVariables(string name); |
||||||
|
} |
||||||
|
} |
||||||
@ -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 ITextTemplatingPathResolver |
||||||
|
{ |
||||||
|
string ResolvePath(string path); |
||||||
|
} |
||||||
|
} |
||||||
@ -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 ITextTemplatingStringParser |
||||||
|
{ |
||||||
|
string GetValue(string propertyName); |
||||||
|
} |
||||||
|
} |
||||||
@ -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; |
||||||
|
|
||||||
|
namespace ICSharpCode.TextTemplating |
||||||
|
{ |
||||||
|
public interface ITextTemplatingVariables |
||||||
|
{ |
||||||
|
string ExpandVariables(string name); |
||||||
|
string GetValue(string name); |
||||||
|
} |
||||||
|
} |
||||||
@ -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.Linq; |
||||||
|
|
||||||
|
namespace ICSharpCode.TextTemplating |
||||||
|
{ |
||||||
|
public static class TextTemplatingDirectoryVariable |
||||||
|
{ |
||||||
|
public static bool IsDirectoryVariable(string name) |
||||||
|
{ |
||||||
|
return name.EndsWith("Dir", StringComparison.OrdinalIgnoreCase); |
||||||
|
} |
||||||
|
|
||||||
|
public static string AppendTrailingSlashIfMissing(string variableValue) |
||||||
|
{ |
||||||
|
if (!String.IsNullOrEmpty(variableValue)) { |
||||||
|
if (variableValue.Last() == '\\') { |
||||||
|
return variableValue; |
||||||
|
} |
||||||
|
return variableValue + "\\"; |
||||||
|
} |
||||||
|
return String.Empty; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,15 @@ |
|||||||
|
// 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 TextTemplatingEnvironment : ITextTemplatingEnvironment |
||||||
|
{ |
||||||
|
public string ExpandEnvironmentVariables(string name) |
||||||
|
{ |
||||||
|
return Environment.ExpandEnvironmentVariables(name); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,57 @@ |
|||||||
|
// 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.Project; |
||||||
|
|
||||||
|
namespace ICSharpCode.TextTemplating |
||||||
|
{ |
||||||
|
public class TextTemplatingHostContext |
||||||
|
{ |
||||||
|
ITextTemplatingAppDomainFactory appDomainFactory; |
||||||
|
ITextTemplatingAssemblyResolver assemblyResolver; |
||||||
|
ITextTemplatingVariables templatingVariables; |
||||||
|
IServiceProvider serviceProvider; |
||||||
|
|
||||||
|
public TextTemplatingHostContext(IProject project) |
||||||
|
: this( |
||||||
|
new TextTemplatingAppDomainFactory(), |
||||||
|
new TextTemplatingAssemblyResolver(project), |
||||||
|
new TextTemplatingVariables(), |
||||||
|
new TextTemplatingServiceProvider()) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public TextTemplatingHostContext( |
||||||
|
ITextTemplatingAppDomainFactory appDomainFactory, |
||||||
|
ITextTemplatingAssemblyResolver assemblyResolver, |
||||||
|
ITextTemplatingVariables templatingVariables, |
||||||
|
IServiceProvider serviceProvider) |
||||||
|
{ |
||||||
|
this.appDomainFactory = appDomainFactory; |
||||||
|
this.assemblyResolver = assemblyResolver; |
||||||
|
this.templatingVariables = templatingVariables; |
||||||
|
this.serviceProvider = serviceProvider; |
||||||
|
} |
||||||
|
|
||||||
|
public object GetService(Type serviceType) |
||||||
|
{ |
||||||
|
return serviceProvider.GetService(serviceType); |
||||||
|
} |
||||||
|
|
||||||
|
public string ExpandTemplateVariables(string name) |
||||||
|
{ |
||||||
|
return templatingVariables.ExpandVariables(name); |
||||||
|
} |
||||||
|
|
||||||
|
public ITextTemplatingAppDomain CreateTextTemplatingAppDomain(string applicationBase) |
||||||
|
{ |
||||||
|
return appDomainFactory.CreateTextTemplatingAppDomain(applicationBase); |
||||||
|
} |
||||||
|
|
||||||
|
public string ResolveAssemblyReference(string assemblyReference) |
||||||
|
{ |
||||||
|
return assemblyResolver.Resolve(assemblyReference); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -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; |
||||||
|
|
||||||
|
namespace ICSharpCode.TextTemplating |
||||||
|
{ |
||||||
|
public class TextTemplatingPathResolver : ITextTemplatingPathResolver |
||||||
|
{ |
||||||
|
ITextTemplatingVariables templatingVariables; |
||||||
|
ITextTemplatingEnvironment environment; |
||||||
|
|
||||||
|
public TextTemplatingPathResolver() |
||||||
|
: this(new TextTemplatingVariables(), new TextTemplatingEnvironment()) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public TextTemplatingPathResolver( |
||||||
|
ITextTemplatingVariables templatingVariables, |
||||||
|
ITextTemplatingEnvironment environment) |
||||||
|
{ |
||||||
|
this.templatingVariables = templatingVariables; |
||||||
|
this.environment = environment; |
||||||
|
} |
||||||
|
|
||||||
|
public string ResolvePath(string path) |
||||||
|
{ |
||||||
|
path = environment.ExpandEnvironmentVariables(path); |
||||||
|
return templatingVariables.ExpandVariables(path); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,15 @@ |
|||||||
|
// 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 TextTemplatingServiceProvider : IServiceProvider |
||||||
|
{ |
||||||
|
public object GetService(Type serviceType) |
||||||
|
{ |
||||||
|
return serviceType.Assembly.CreateInstance(serviceType.FullName); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -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 ICSharpCode.Core; |
||||||
|
|
||||||
|
namespace ICSharpCode.TextTemplating |
||||||
|
{ |
||||||
|
public class TextTemplatingStringParser : ITextTemplatingStringParser |
||||||
|
{ |
||||||
|
public string GetValue(string propertyName) |
||||||
|
{ |
||||||
|
return StringParser.GetValue(propertyName); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,75 @@ |
|||||||
|
// 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 TextTemplatingVariableLocation |
||||||
|
{ |
||||||
|
public TextTemplatingVariableLocation() |
||||||
|
: this(String.Empty, 0, 0) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public TextTemplatingVariableLocation( |
||||||
|
string variableName, |
||||||
|
int index, |
||||||
|
int length) |
||||||
|
{ |
||||||
|
this.VariableName = variableName; |
||||||
|
this.Index = index; |
||||||
|
this.Length = length; |
||||||
|
} |
||||||
|
|
||||||
|
public static TextTemplatingVariableLocation CreateFromString( |
||||||
|
string text, |
||||||
|
int unexpandedVariableStartIndex, |
||||||
|
int unexpandedVariableEndIndex) |
||||||
|
{ |
||||||
|
int variableNameStart = unexpandedVariableStartIndex + 2; |
||||||
|
int unexpandedLength = unexpandedVariableEndIndex - unexpandedVariableStartIndex + 1; |
||||||
|
string variableName = text.Substring(variableNameStart, unexpandedVariableEndIndex - variableNameStart); |
||||||
|
return new TextTemplatingVariableLocation(variableName, unexpandedVariableStartIndex, unexpandedLength); |
||||||
|
} |
||||||
|
|
||||||
|
public string VariableName { get; set; } |
||||||
|
public int Index { get; set; } |
||||||
|
public int Length { get; set; } |
||||||
|
|
||||||
|
public override bool Equals(object obj) |
||||||
|
{ |
||||||
|
var rhs = obj as TextTemplatingVariableLocation; |
||||||
|
if (rhs != null) { |
||||||
|
return (VariableName == rhs.VariableName) && |
||||||
|
(Index == rhs.Index) && |
||||||
|
(Length == rhs.Length); |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
public override int GetHashCode() |
||||||
|
{ |
||||||
|
return base.GetHashCode(); |
||||||
|
} |
||||||
|
|
||||||
|
public override string ToString() |
||||||
|
{ |
||||||
|
return String.Format( |
||||||
|
"VariableName: {0}, Index: {1}, Length: {2}", |
||||||
|
VariableName, Index, Length); |
||||||
|
} |
||||||
|
|
||||||
|
public static TextTemplatingVariableLocation FindVariable(string text, int startSearchIndex) |
||||||
|
{ |
||||||
|
int start = text.IndexOf("$(", startSearchIndex); |
||||||
|
if (start >= 0) { |
||||||
|
int end = text.IndexOf(")", start); |
||||||
|
if (end >= 0) { |
||||||
|
return CreateFromString(text, start, end); |
||||||
|
} |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,92 @@ |
|||||||
|
// 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.Linq; |
||||||
|
using System.Text; |
||||||
|
|
||||||
|
namespace ICSharpCode.TextTemplating |
||||||
|
{ |
||||||
|
public class TextTemplatingVariables : ITextTemplatingVariables |
||||||
|
{ |
||||||
|
ITextTemplatingStringParser stringParser; |
||||||
|
|
||||||
|
public TextTemplatingVariables() |
||||||
|
: this(new TextTemplatingStringParser()) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public TextTemplatingVariables( |
||||||
|
ITextTemplatingStringParser stringParser) |
||||||
|
{ |
||||||
|
this.stringParser = stringParser; |
||||||
|
} |
||||||
|
|
||||||
|
public string ExpandVariables(string name) |
||||||
|
{ |
||||||
|
var variablesBuilder = new TextTemplatingVariablesStringBuilder(name, this); |
||||||
|
foreach (TextTemplatingVariableLocation variableLocation in GetVariables(name)) { |
||||||
|
variablesBuilder.AppendTextBeforeVariable(variableLocation); |
||||||
|
variablesBuilder.AppendVariable(variableLocation); |
||||||
|
} |
||||||
|
variablesBuilder.AppendRemaining(); |
||||||
|
return variablesBuilder.ToString(); |
||||||
|
} |
||||||
|
|
||||||
|
public IEnumerable<TextTemplatingVariableLocation> GetVariables(string text) |
||||||
|
{ |
||||||
|
if (String.IsNullOrEmpty(text)) { |
||||||
|
yield break; |
||||||
|
} |
||||||
|
|
||||||
|
int currentIndex = 0; |
||||||
|
while (true) { |
||||||
|
TextTemplatingVariableLocation variableLocation = |
||||||
|
FindVariable(text, currentIndex); |
||||||
|
if (variableLocation != null) { |
||||||
|
currentIndex = variableLocation.Index + variableLocation.Length; |
||||||
|
yield return variableLocation; |
||||||
|
} else { |
||||||
|
yield break; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
TextTemplatingVariableLocation FindVariable(string text, int startIndex) |
||||||
|
{ |
||||||
|
return TextTemplatingVariableLocation.FindVariable(text, startIndex); |
||||||
|
} |
||||||
|
|
||||||
|
public string GetValue(string name) |
||||||
|
{ |
||||||
|
if (name == null) { |
||||||
|
return String.Empty; |
||||||
|
} |
||||||
|
|
||||||
|
string variableValue = stringParser.GetValue(name); |
||||||
|
if (IsDirectoryVariable(name)) { |
||||||
|
return AppendTrailingSlashIfMissing(variableValue); |
||||||
|
} |
||||||
|
return GetEmptyStringIfNull(variableValue); |
||||||
|
} |
||||||
|
|
||||||
|
bool IsDirectoryVariable(string name) |
||||||
|
{ |
||||||
|
return TextTemplatingDirectoryVariable.IsDirectoryVariable(name); |
||||||
|
} |
||||||
|
|
||||||
|
string AppendTrailingSlashIfMissing(string variableValue) |
||||||
|
{ |
||||||
|
return TextTemplatingDirectoryVariable.AppendTrailingSlashIfMissing(variableValue); |
||||||
|
} |
||||||
|
|
||||||
|
string GetEmptyStringIfNull(string variableValue) |
||||||
|
{ |
||||||
|
if (variableValue != null) { |
||||||
|
return variableValue; |
||||||
|
} |
||||||
|
return String.Empty; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -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.Text; |
||||||
|
|
||||||
|
namespace ICSharpCode.TextTemplating |
||||||
|
{ |
||||||
|
public class TextTemplatingVariablesStringBuilder |
||||||
|
{ |
||||||
|
StringBuilder variablesBuilder = new StringBuilder(); |
||||||
|
string unexpandedVariablesString; |
||||||
|
ITextTemplatingVariables templatingVariables; |
||||||
|
int currentIndex; |
||||||
|
|
||||||
|
public TextTemplatingVariablesStringBuilder( |
||||||
|
string unexpandedVariablesString, |
||||||
|
ITextTemplatingVariables templatingVariables) |
||||||
|
{ |
||||||
|
this.unexpandedVariablesString = unexpandedVariablesString; |
||||||
|
this.templatingVariables = templatingVariables; |
||||||
|
} |
||||||
|
|
||||||
|
public void Append(string text) |
||||||
|
{ |
||||||
|
variablesBuilder.Append(text); |
||||||
|
} |
||||||
|
|
||||||
|
public override string ToString() |
||||||
|
{ |
||||||
|
return variablesBuilder.ToString(); |
||||||
|
} |
||||||
|
|
||||||
|
public void AppendVariable(TextTemplatingVariableLocation variableLocation) |
||||||
|
{ |
||||||
|
AppendVariableText(variableLocation); |
||||||
|
UpdateCurrentIndex(variableLocation); |
||||||
|
} |
||||||
|
|
||||||
|
public void AppendTextBeforeVariable(TextTemplatingVariableLocation variableLocation) |
||||||
|
{ |
||||||
|
string textBeforeVariable = unexpandedVariablesString.Substring(currentIndex, variableLocation.Index); |
||||||
|
variablesBuilder.Append(textBeforeVariable); |
||||||
|
} |
||||||
|
|
||||||
|
void AppendVariableText(TextTemplatingVariableLocation variableLocation) |
||||||
|
{ |
||||||
|
string variableValue = GetVariableValue(variableLocation); |
||||||
|
variablesBuilder.Append(variableValue); |
||||||
|
} |
||||||
|
|
||||||
|
void UpdateCurrentIndex(TextTemplatingVariableLocation variableLocation) |
||||||
|
{ |
||||||
|
currentIndex = variableLocation.Index + variableLocation.Length; |
||||||
|
} |
||||||
|
|
||||||
|
string GetVariableValue(TextTemplatingVariableLocation variableLocation) |
||||||
|
{ |
||||||
|
return templatingVariables.GetValue(variableLocation.VariableName); |
||||||
|
} |
||||||
|
|
||||||
|
public void AppendRemaining() |
||||||
|
{ |
||||||
|
string textNotAppended = GetTextNotAppended(); |
||||||
|
variablesBuilder.Append(textNotAppended); |
||||||
|
} |
||||||
|
|
||||||
|
string GetTextNotAppended() |
||||||
|
{ |
||||||
|
return unexpandedVariablesString.Substring(currentIndex); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,25 @@ |
|||||||
|
// 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 TextTemplating.Tests.Helpers |
||||||
|
{ |
||||||
|
public class FakeServiceProvider : IServiceProvider |
||||||
|
{ |
||||||
|
public Dictionary<Type, object> Services = new Dictionary<Type, object>(); |
||||||
|
|
||||||
|
public void AddService(Type serviceType, object service) |
||||||
|
{ |
||||||
|
Services.Add(serviceType, service); |
||||||
|
} |
||||||
|
|
||||||
|
public object GetService(Type serviceType) |
||||||
|
{ |
||||||
|
object service = null; |
||||||
|
Services.TryGetValue(serviceType, out service); |
||||||
|
return service; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,29 @@ |
|||||||
|
// 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.TextTemplating; |
||||||
|
|
||||||
|
namespace TextTemplating.Tests.Helpers |
||||||
|
{ |
||||||
|
public class FakeTextTemplatingEnvironment : ITextTemplatingEnvironment |
||||||
|
{ |
||||||
|
public Dictionary<string, string> Variables = new Dictionary<string, string>(); |
||||||
|
|
||||||
|
public string ExpandEnvironmentVariables(string name) |
||||||
|
{ |
||||||
|
string value = null; |
||||||
|
if (Variables.TryGetValue(name, out value)) { |
||||||
|
return value; |
||||||
|
} |
||||||
|
return name; |
||||||
|
} |
||||||
|
|
||||||
|
public void AddVariable(string name, string value) |
||||||
|
{ |
||||||
|
name = "%" + name + "%"; |
||||||
|
Variables.Add(name, value); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -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 ICSharpCode.TextTemplating; |
||||||
|
|
||||||
|
namespace TextTemplating.Tests.Helpers |
||||||
|
{ |
||||||
|
public class FakeTextTemplatingPathResolver : ITextTemplatingPathResolver |
||||||
|
{ |
||||||
|
public Dictionary<string, string> Paths = new Dictionary<string, string>(); |
||||||
|
|
||||||
|
public string ResolvePath(string path) |
||||||
|
{ |
||||||
|
string resolvedPath = null; |
||||||
|
if (Paths.TryGetValue(path, out resolvedPath)) { |
||||||
|
return resolvedPath; |
||||||
|
} |
||||||
|
return path; |
||||||
|
} |
||||||
|
|
||||||
|
public void AddPath(string path, string resolvedPath) |
||||||
|
{ |
||||||
|
Paths.Add(path, resolvedPath); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,26 @@ |
|||||||
|
// 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.TextTemplating; |
||||||
|
|
||||||
|
namespace TextTemplating.Tests.Helpers |
||||||
|
{ |
||||||
|
public class FakeTextTemplatingStringParser : ITextTemplatingStringParser |
||||||
|
{ |
||||||
|
public Dictionary<string, string> Properties = new Dictionary<string, string>(); |
||||||
|
|
||||||
|
public string GetValue(string propertyName) |
||||||
|
{ |
||||||
|
string propertyValue = null; |
||||||
|
Properties.TryGetValue(propertyName, out propertyValue); |
||||||
|
return propertyValue; |
||||||
|
} |
||||||
|
|
||||||
|
public void AddProperty(string name, string value) |
||||||
|
{ |
||||||
|
Properties.Add(name, value); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,35 @@ |
|||||||
|
// 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.TextTemplating; |
||||||
|
|
||||||
|
namespace TextTemplating.Tests.Helpers |
||||||
|
{ |
||||||
|
public class FakeTextTemplatingVariables : ITextTemplatingVariables |
||||||
|
{ |
||||||
|
public Dictionary<string, string> Variables = new Dictionary<string, string>(); |
||||||
|
|
||||||
|
public void AddVariable(string name, string value) |
||||||
|
{ |
||||||
|
name = "$(" + name + ")"; |
||||||
|
Variables.Add(name, value); |
||||||
|
} |
||||||
|
|
||||||
|
public string ExpandVariables(string name) |
||||||
|
{ |
||||||
|
foreach (KeyValuePair<string, string> variable in Variables) { |
||||||
|
name = name.Replace(variable.Key, variable.Value); |
||||||
|
} |
||||||
|
return name; |
||||||
|
} |
||||||
|
|
||||||
|
public string GetValue(string name) |
||||||
|
{ |
||||||
|
string variableValue = null; |
||||||
|
Variables.TryGetValue(name, out variableValue); |
||||||
|
return variableValue; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,57 @@ |
|||||||
|
// 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 TextTemplatingPathResolverTests |
||||||
|
{ |
||||||
|
TextTemplatingPathResolver pathResolver; |
||||||
|
FakeTextTemplatingVariables fakeTemplatingVariables; |
||||||
|
FakeTextTemplatingEnvironment fakeEnvironment; |
||||||
|
|
||||||
|
void CreatePathResolver() |
||||||
|
{ |
||||||
|
fakeTemplatingVariables = new FakeTextTemplatingVariables(); |
||||||
|
fakeEnvironment = new FakeTextTemplatingEnvironment(); |
||||||
|
pathResolver = new TextTemplatingPathResolver(fakeTemplatingVariables, fakeEnvironment); |
||||||
|
} |
||||||
|
|
||||||
|
void AddEnvironmentVariable(string name, string value) |
||||||
|
{ |
||||||
|
fakeEnvironment.AddVariable(name, value); |
||||||
|
} |
||||||
|
|
||||||
|
void AddTemplateVariable(string name, string value) |
||||||
|
{ |
||||||
|
fakeTemplatingVariables.AddVariable(name, value); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ResolvePath_EnvironmentVariableInPath_ReturnsPathWithEnvironmentVariableExpanded() |
||||||
|
{ |
||||||
|
CreatePathResolver(); |
||||||
|
AddEnvironmentVariable("windir", @"c:\windows"); |
||||||
|
|
||||||
|
string path = pathResolver.ResolvePath("%windir%"); |
||||||
|
|
||||||
|
Assert.AreEqual(@"c:\windows", path); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ResolvePath_TemplateVariableInPath_ReturnsPathWithTemplateVariableExpanded() |
||||||
|
{ |
||||||
|
CreatePathResolver(); |
||||||
|
AddTemplateVariable("SolutionDir", @"d:\projects\MyApp\"); |
||||||
|
|
||||||
|
string path = pathResolver.ResolvePath("$(SolutionDir)"); |
||||||
|
|
||||||
|
Assert.AreEqual(@"d:\projects\MyApp\", path); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,30 @@ |
|||||||
|
// 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 TextTemplatingServiceProviderTests |
||||||
|
{ |
||||||
|
TextTemplatingServiceProvider serviceProvider; |
||||||
|
|
||||||
|
void CreateServiceProvider() |
||||||
|
{ |
||||||
|
serviceProvider = new TextTemplatingServiceProvider(); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetService_TypeOfFakeServiceProvider_ReturnsNewFakeServiceProvider() |
||||||
|
{ |
||||||
|
CreateServiceProvider(); |
||||||
|
FakeServiceProvider service = serviceProvider.GetService(typeof(FakeServiceProvider)) as FakeServiceProvider; |
||||||
|
|
||||||
|
Assert.IsNotNull(service); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,78 @@ |
|||||||
|
// 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 |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class TextTemplatingVariableLocationTests |
||||||
|
{ |
||||||
|
TextTemplatingVariableLocation lhs; |
||||||
|
TextTemplatingVariableLocation rhs; |
||||||
|
|
||||||
|
void CreateVariableLocationsToCompare() |
||||||
|
{ |
||||||
|
lhs = new TextTemplatingVariableLocation(); |
||||||
|
rhs = new TextTemplatingVariableLocation(); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Equals_AllPropertiesSame_ReturnsTrue() |
||||||
|
{ |
||||||
|
CreateVariableLocationsToCompare(); |
||||||
|
|
||||||
|
bool result = lhs.Equals(rhs); |
||||||
|
|
||||||
|
Assert.IsTrue(result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Equals_VariableNamesAreDifferent_ReturnsFalse() |
||||||
|
{ |
||||||
|
CreateVariableLocationsToCompare(); |
||||||
|
lhs.VariableName = "A"; |
||||||
|
rhs.VariableName = "B"; |
||||||
|
|
||||||
|
bool result = lhs.Equals(rhs); |
||||||
|
|
||||||
|
Assert.IsFalse(result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Equals_NullPassed_ReturnsFalse() |
||||||
|
{ |
||||||
|
CreateVariableLocationsToCompare(); |
||||||
|
|
||||||
|
bool result = lhs.Equals(null); |
||||||
|
|
||||||
|
Assert.IsFalse(result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Equals_IndexesAreDifferent_ReturnsFalse() |
||||||
|
{ |
||||||
|
CreateVariableLocationsToCompare(); |
||||||
|
lhs.Index = 1; |
||||||
|
rhs.Index = 3; |
||||||
|
|
||||||
|
bool result = lhs.Equals(rhs); |
||||||
|
|
||||||
|
Assert.IsFalse(result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Equals_LengthsAreDifferent_ReturnsFalse() |
||||||
|
{ |
||||||
|
CreateVariableLocationsToCompare(); |
||||||
|
lhs.Length = 1; |
||||||
|
rhs.Length = 3; |
||||||
|
|
||||||
|
bool result = lhs.Equals(rhs); |
||||||
|
|
||||||
|
Assert.IsFalse(result); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,241 @@ |
|||||||
|
// 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.Linq; |
||||||
|
using ICSharpCode.TextTemplating; |
||||||
|
using NUnit.Framework; |
||||||
|
using TextTemplating.Tests.Helpers; |
||||||
|
|
||||||
|
namespace TextTemplating.Tests |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class TextTemplatingVariablesTests |
||||||
|
{ |
||||||
|
TextTemplatingVariables variables; |
||||||
|
FakeTextTemplatingStringParser fakeStringParser; |
||||||
|
|
||||||
|
void CreateTextTemplatingVariables() |
||||||
|
{ |
||||||
|
fakeStringParser = new FakeTextTemplatingStringParser(); |
||||||
|
variables = new TextTemplatingVariables(fakeStringParser); |
||||||
|
} |
||||||
|
|
||||||
|
void AddProperty(string name, string value) |
||||||
|
{ |
||||||
|
fakeStringParser.AddProperty(name, value); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ExpandVariables_SolutionDirProperty_SolutionDirPropertyIsExpanded() |
||||||
|
{ |
||||||
|
CreateTextTemplatingVariables(); |
||||||
|
AddProperty("SolutionDir", @"d:\projects\MyProject\"); |
||||||
|
|
||||||
|
string result = variables.ExpandVariables(@"$(SolutionDir)bin\Debug\Test.dll"); |
||||||
|
|
||||||
|
string expectedResult = @"d:\projects\MyProject\bin\Debug\Test.dll"; |
||||||
|
Assert.AreEqual(expectedResult, result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ExpandVariables_ProjectDirProperty_ProjectDirPropertyIsExpanded() |
||||||
|
{ |
||||||
|
CreateTextTemplatingVariables(); |
||||||
|
AddProperty("ProjectDir", @"d:\projects\MyProject\"); |
||||||
|
|
||||||
|
string result = variables.ExpandVariables(@"$(ProjectDir)bin\Debug\Test.dll"); |
||||||
|
|
||||||
|
string expectedResult = @"d:\projects\MyProject\bin\Debug\Test.dll"; |
||||||
|
Assert.AreEqual(expectedResult, result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetVariableLocations_SolutionDirProperty_ReturnsSolutionDirVariable() |
||||||
|
{ |
||||||
|
CreateTextTemplatingVariables(); |
||||||
|
|
||||||
|
TextTemplatingVariableLocation location = variables.GetVariables("$(SolutionDir)").First(); |
||||||
|
|
||||||
|
var expectedLocation = new TextTemplatingVariableLocation() { |
||||||
|
VariableName = "SolutionDir", |
||||||
|
Index = 0, |
||||||
|
Length = 14 |
||||||
|
}; |
||||||
|
|
||||||
|
Assert.AreEqual(expectedLocation, location); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetVariableLocations_NullPassed_ReturnsNoVariables() |
||||||
|
{ |
||||||
|
CreateTextTemplatingVariables(); |
||||||
|
List<TextTemplatingVariableLocation> locations = |
||||||
|
variables.GetVariables(null).ToList(); |
||||||
|
|
||||||
|
Assert.AreEqual(0, locations.Count); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetVariableLocations_EmptyStringPassed_ReturnsNoVariables() |
||||||
|
{ |
||||||
|
CreateTextTemplatingVariables(); |
||||||
|
List<TextTemplatingVariableLocation> locations = |
||||||
|
variables.GetVariables(String.Empty).ToList(); |
||||||
|
|
||||||
|
Assert.AreEqual(0, locations.Count); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetVariableLocations_TextHasNoVariables_ReturnsNoVariables() |
||||||
|
{ |
||||||
|
CreateTextTemplatingVariables(); |
||||||
|
List<TextTemplatingVariableLocation> locations = |
||||||
|
variables.GetVariables("No Variables").ToList(); |
||||||
|
|
||||||
|
Assert.AreEqual(0, locations.Count); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetVariableLocations_TextHasVariableStartButNoEnd_ReturnsNoVariables() |
||||||
|
{ |
||||||
|
CreateTextTemplatingVariables(); |
||||||
|
List<TextTemplatingVariableLocation> locations = |
||||||
|
variables.GetVariables("$(No Variables").ToList(); |
||||||
|
|
||||||
|
Assert.AreEqual(0, locations.Count); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetVariableLocations_TwoProperties_ReturnsTwoVariables() |
||||||
|
{ |
||||||
|
CreateTextTemplatingVariables(); |
||||||
|
|
||||||
|
List<TextTemplatingVariableLocation> locations = |
||||||
|
variables.GetVariables("$(SolutionDir)$(ProjectDir)").ToList(); |
||||||
|
|
||||||
|
var expectedLocation1 = new TextTemplatingVariableLocation() { |
||||||
|
VariableName = "SolutionDir", |
||||||
|
Index = 0, |
||||||
|
Length = 14 |
||||||
|
}; |
||||||
|
|
||||||
|
var expectedLocation2 = new TextTemplatingVariableLocation() { |
||||||
|
VariableName = "ProjectDir", |
||||||
|
Index = 14, |
||||||
|
Length = 13 |
||||||
|
}; |
||||||
|
|
||||||
|
var expectedLocations = new TextTemplatingVariableLocation[] { |
||||||
|
expectedLocation1, |
||||||
|
expectedLocation2 |
||||||
|
}; |
||||||
|
|
||||||
|
CollectionAssert.AreEqual(expectedLocations, locations); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetValue_ProjectDirProperty_ReturnsProjectDir() |
||||||
|
{ |
||||||
|
CreateTextTemplatingVariables(); |
||||||
|
AddProperty("ProjectDir", @"d:\projects\MyProject\"); |
||||||
|
|
||||||
|
string variableValue = variables.GetValue("ProjectDir"); |
||||||
|
|
||||||
|
string expectedVariableValue = @"d:\projects\MyProject\"; |
||||||
|
Assert.AreEqual(expectedVariableValue, variableValue); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetValue_ProjectDirPropertyHasNoTrailingSlash_ReturnsProjectDirWithTrailingSlash() |
||||||
|
{ |
||||||
|
CreateTextTemplatingVariables(); |
||||||
|
AddProperty("ProjectDir", @"d:\projects\MyProject"); |
||||||
|
|
||||||
|
string variableValue = variables.GetValue("ProjectDir"); |
||||||
|
|
||||||
|
string expectedVariableValue = @"d:\projects\MyProject\"; |
||||||
|
Assert.AreEqual(expectedVariableValue, variableValue); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetValue_PropertyReturnsEmptyStringAsValue_ReturnsEmptyString() |
||||||
|
{ |
||||||
|
CreateTextTemplatingVariables(); |
||||||
|
AddProperty("ProjectDir", String.Empty); |
||||||
|
|
||||||
|
string variableValue = variables.GetValue("ProjectDir"); |
||||||
|
|
||||||
|
Assert.AreEqual(String.Empty, variableValue); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetValue_PropertyReturnsNullAsValue_ReturnsEmptyString() |
||||||
|
{ |
||||||
|
CreateTextTemplatingVariables(); |
||||||
|
AddProperty("Test", null); |
||||||
|
|
||||||
|
string variableValue = variables.GetValue("Test"); |
||||||
|
|
||||||
|
Assert.AreEqual(String.Empty, variableValue); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetValue_NonDirectoryPropertyReturnsNonEmptyStringAsValue_DoesNotAppendTrailingSlash() |
||||||
|
{ |
||||||
|
CreateTextTemplatingVariables(); |
||||||
|
AddProperty("Test", "abc"); |
||||||
|
|
||||||
|
string variableValue = variables.GetValue("Test"); |
||||||
|
|
||||||
|
Assert.AreEqual("abc", variableValue); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetValue_SolutionDirPropertyWithoutTrailingSlash_ReturnsExpandedSolutionDirWithTrailingSlash() |
||||||
|
{ |
||||||
|
CreateTextTemplatingVariables(); |
||||||
|
AddProperty("SolutionDir", @"d:\projects\MySolution"); |
||||||
|
|
||||||
|
string variableValue = variables.GetValue("SolutionDir"); |
||||||
|
|
||||||
|
string expectedVariableValue = @"d:\projects\MySolution\"; |
||||||
|
Assert.AreEqual(expectedVariableValue, variableValue); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetValue_SolutionDirPropertyInLowerCaseWithoutTrailingSlash_ReturnsExpandedSolutionDirWithTrailingSlash() |
||||||
|
{ |
||||||
|
CreateTextTemplatingVariables(); |
||||||
|
AddProperty("solutiondir", @"d:\projects\MySolution"); |
||||||
|
|
||||||
|
string variableValue = variables.GetValue("solutiondir"); |
||||||
|
|
||||||
|
string expectedVariableValue = @"d:\projects\MySolution\"; |
||||||
|
Assert.AreEqual(expectedVariableValue, variableValue); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetValue_NullPassed_ReturnsEmptyString() |
||||||
|
{ |
||||||
|
CreateTextTemplatingVariables(); |
||||||
|
|
||||||
|
string variableValue = variables.GetValue(null); |
||||||
|
|
||||||
|
Assert.AreEqual(String.Empty, variableValue); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ExpandVariables_ProjectDirPropertyHasNoTrailingSlash_ProjectDirPropertyIsExpandedWithTrailingSlash() |
||||||
|
{ |
||||||
|
CreateTextTemplatingVariables(); |
||||||
|
AddProperty("ProjectDir", @"d:\projects\MyProject"); |
||||||
|
|
||||||
|
string result = variables.ExpandVariables(@"$(ProjectDir)bin\Debug\Test.dll"); |
||||||
|
|
||||||
|
string expectedResult = @"d:\projects\MyProject\bin\Debug\Test.dll"; |
||||||
|
Assert.AreEqual(expectedResult, result); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue