17 changed files with 745 additions and 4 deletions
@ -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 ITextTemplatingStringParser |
||||
{ |
||||
string GetValue(string propertyName); |
||||
} |
||||
} |
||||
@ -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; |
||||
|
||||
namespace ICSharpCode.TextTemplating |
||||
{ |
||||
public interface ITextTemplatingVariables |
||||
{ |
||||
string Expand(string name); |
||||
string GetValue(string name); |
||||
} |
||||
} |
||||
@ -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.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,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 ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.TextTemplating |
||||
{ |
||||
public class TextTemplatingStringParser : ITextTemplatingStringParser |
||||
{ |
||||
public string GetValue(string propertyName) |
||||
{ |
||||
return StringParser.GetValue(propertyName); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,75 @@
@@ -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 @@
@@ -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 Expand(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 @@
@@ -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,26 @@
@@ -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,34 @@
@@ -0,0 +1,34 @@
|
||||
// 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) |
||||
{ |
||||
Variables.Add(name, value); |
||||
} |
||||
|
||||
public string Expand(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,78 @@
@@ -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 @@
@@ -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 Expand_SolutionDirProperty_SolutionDirPropertyIsExpanded() |
||||
{ |
||||
CreateTextTemplatingVariables(); |
||||
AddProperty("SolutionDir", @"d:\projects\MyProject\"); |
||||
|
||||
string result = variables.Expand(@"$(SolutionDir)bin\Debug\Test.dll"); |
||||
|
||||
string expectedResult = @"d:\projects\MyProject\bin\Debug\Test.dll"; |
||||
Assert.AreEqual(expectedResult, result); |
||||
} |
||||
|
||||
[Test] |
||||
public void Expand_ProjectDirProperty_ProjectDirPropertyIsExpanded() |
||||
{ |
||||
CreateTextTemplatingVariables(); |
||||
AddProperty("ProjectDir", @"d:\projects\MyProject\"); |
||||
|
||||
string result = variables.Expand(@"$(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 Expand_ProjectDirPropertyHasNoTrailingSlash_ProjectDirPropertyIsExpandedWithTrailingSlash() |
||||
{ |
||||
CreateTextTemplatingVariables(); |
||||
AddProperty("ProjectDir", @"d:\projects\MyProject"); |
||||
|
||||
string result = variables.Expand(@"$(ProjectDir)bin\Debug\Test.dll"); |
||||
|
||||
string expectedResult = @"d:\projects\MyProject\bin\Debug\Test.dll"; |
||||
Assert.AreEqual(expectedResult, result); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue