Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
Refactor TextTemplatingVariables class.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrward committed Sep 25, 2011
1 parent 07b9251 commit 092b913
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace ICSharpCode.TextTemplating
{
public interface ITextTemplatingVariables
{
string Expand(string name);
string ExpandVariables(string name);
string GetValue(string name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected override string ResolvePath(string path)

string ExpandPath(string path)
{
return templatingVariables.Expand(path);
return templatingVariables.ExpandVariables(path);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public TextTemplatingPathResolver(
public string ResolvePath(string path)
{
path = environment.ExpandEnvironmentVariables(path);
return templatingVariables.Expand(path);
return templatingVariables.ExpandVariables(path);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public TextTemplatingVariables(
this.stringParser = stringParser;
}

public string Expand(string name)
public string ExpandVariables(string name)
{
var variablesBuilder = new TextTemplatingVariablesStringBuilder(name, this);
foreach (TextTemplatingVariableLocation variableLocation in GetVariables(name)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void AddVariable(string name, string value)
Variables.Add(name, value);
}

public string Expand(string name)
public string ExpandVariables(string name)
{
foreach (KeyValuePair<string, string> variable in Variables) {
name = name.Replace(variable.Key, variable.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ void AddProperty(string name, string value)
}

[Test]
public void Expand_SolutionDirProperty_SolutionDirPropertyIsExpanded()
public void ExpandVariables_SolutionDirProperty_SolutionDirPropertyIsExpanded()
{
CreateTextTemplatingVariables();
AddProperty("SolutionDir", @"d:\projects\MyProject\");

string result = variables.Expand(@"$(SolutionDir)bin\Debug\Test.dll");
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 Expand_ProjectDirProperty_ProjectDirPropertyIsExpanded()
public void ExpandVariables_ProjectDirProperty_ProjectDirPropertyIsExpanded()
{
CreateTextTemplatingVariables();
AddProperty("ProjectDir", @"d:\projects\MyProject\");

string result = variables.Expand(@"$(ProjectDir)bin\Debug\Test.dll");
string result = variables.ExpandVariables(@"$(ProjectDir)bin\Debug\Test.dll");

string expectedResult = @"d:\projects\MyProject\bin\Debug\Test.dll";
Assert.AreEqual(expectedResult, result);
Expand Down Expand Up @@ -227,12 +227,12 @@ public void GetValue_NullPassed_ReturnsEmptyString()
}

[Test]
public void Expand_ProjectDirPropertyHasNoTrailingSlash_ProjectDirPropertyIsExpandedWithTrailingSlash()
public void ExpandVariables_ProjectDirPropertyHasNoTrailingSlash_ProjectDirPropertyIsExpandedWithTrailingSlash()
{
CreateTextTemplatingVariables();
AddProperty("ProjectDir", @"d:\projects\MyProject");

string result = variables.Expand(@"$(ProjectDir)bin\Debug\Test.dll");
string result = variables.ExpandVariables(@"$(ProjectDir)bin\Debug\Test.dll");

string expectedResult = @"d:\projects\MyProject\bin\Debug\Test.dll";
Assert.AreEqual(expectedResult, result);
Expand Down

0 comments on commit 092b913

Please sign in to comment.