Exemplo n.º 1
0
        public virtual void RenderWithSavedPayloads(IPayloadValueRetriever valueRetriever, IEnumerable<Payload> payloads)
        {
            var httpRequestOptionProperties = GetType().GetProperties(BindingFlags);
            var payloadArray = payloads.ToArray();
                                    
            foreach (var httpRequestOptionProperty in httpRequestOptionProperties)
            {
                var oldValue = GetRequestOptionValue(httpRequestOptionProperty);
                var regEx = new Regex(@"\{\D+\}");
                var matchCollection = regEx.Matches(oldValue);
                foreach (var match in matchCollection)
                {
                    var matchWithoutBraces = match.ToString().Replace("{", "").Replace("}", "");
                    var replacementValue = valueRetriever.Retrieve(matchWithoutBraces, payloadArray.ToArray());
                    var newValue = regEx.Replace(oldValue, (string) replacementValue);

                    if (_renderedValues.ContainsKey(httpRequestOptionProperty.Name))
                    {
                        _renderedValues[httpRequestOptionProperty.Name] = newValue;
                    }
                    else
                    {
                        _renderedValues.Add(httpRequestOptionProperty.Name, newValue);
                    }
                }                
            }                       
        }
 public AssertJavascriptStepStrategy(IPayloadValueRetriever valueRetriever)
 {
     _valueRetriever = valueRetriever;
 }