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);
		}
        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;
                }
            }
        }
Beispiel #3
0
 string GetVariableValue(TextTemplatingVariableLocation variableLocation)
 {
     return(templatingVariables.GetValue(variableLocation.VariableName));
 }
Beispiel #4
0
 void UpdateCurrentIndex(TextTemplatingVariableLocation variableLocation)
 {
     currentIndex = variableLocation.Index + variableLocation.Length;
 }
Beispiel #5
0
        void AppendVariableText(TextTemplatingVariableLocation variableLocation)
        {
            string variableValue = GetVariableValue(variableLocation);

            variablesBuilder.Append(variableValue);
        }
Beispiel #6
0
        public void AppendTextBeforeVariable(TextTemplatingVariableLocation variableLocation)
        {
            string textBeforeVariable = unexpandedVariablesString.Substring(currentIndex, variableLocation.Index);

            variablesBuilder.Append(textBeforeVariable);
        }
Beispiel #7
0
 public void AppendVariable(TextTemplatingVariableLocation variableLocation)
 {
     AppendVariableText(variableLocation);
     UpdateCurrentIndex(variableLocation);
 }
        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);
        }
 void CreateVariableLocationsToCompare()
 {
     lhs = new TextTemplatingVariableLocation();
     rhs = new TextTemplatingVariableLocation();
 }
 TextTemplatingVariableLocation FindVariable(string text, int startIndex)
 {
     return(TextTemplatingVariableLocation.FindVariable(text, startIndex));
 }
 void UpdateCurrentIndex(TextTemplatingVariableLocation variableLocation)
 {
     currentIndex = variableLocation.Index + variableLocation.Length;
 }
 string GetVariableValue(TextTemplatingVariableLocation variableLocation)
 {
     return templatingVariables.GetValue(variableLocation.VariableName);
 }
 void AppendVariableText(TextTemplatingVariableLocation variableLocation)
 {
     string variableValue = GetVariableValue(variableLocation);
     variablesBuilder.Append(variableValue);
 }
 public void AppendVariable(TextTemplatingVariableLocation variableLocation)
 {
     AppendVariableText(variableLocation);
     UpdateCurrentIndex(variableLocation);
 }
 public void AppendTextBeforeVariable(TextTemplatingVariableLocation variableLocation)
 {
     string textBeforeVariable = unexpandedVariablesString.Substring(currentIndex, variableLocation.Index);
     variablesBuilder.Append(textBeforeVariable);
 }