Pepino.ScenarioRunner.Application.ScenarioContext.Interpret C# (CSharp) Method

Interpret() public method

public Interpret ( string stringWithTokens ) : string
stringWithTokens string
return string
        public string Interpret(string stringWithTokens)
        {
            foreach (var pair in _tokenDictionary)
            {
                stringWithTokens = stringWithTokens.Replace(string.Format("%{0}%", pair.Key), pair.Value);
            }
            return stringWithTokens;
        }
    }

Usage Example

Ejemplo n.º 1
0
 public virtual void ApplyContext(ScenarioContext scenarioContext)
 {
     foreach (var criterion in Criteria)
     {
         foreach (var step in criterion.Steps)
         {
             var propertyInfos = step.GetType().GetProperties();
             foreach (var propertyInfo in propertyInfos)
             {
                 if (propertyInfo.PropertyType==typeof(string))
                 {
                     var oldValue = propertyInfo.GetValue(step).ToString();
                     var newValue = scenarioContext.Interpret(oldValue);
                     if(propertyInfo.SetMethod!=null)
                         propertyInfo.SetValue(step, newValue);
                 }
             }
         }
     }
 }