public void OnDependencyDetectorUrl_IsDependency() { var dep = new DependencyDetector(); Assert.IsTrue(dep.IsDependency("http://localhost:59635/api/UserCrud/${call1.response}")); Assert.IsTrue(dep.IsDependency("http://localhost:59635/api/UserCrud/${call2.request}/resource")); }
public void OnDependencyDetector_IsDependency() { var dep = new DependencyDetector(); Assert.IsTrue(dep.IsDependency("${call1.response}")); Assert.IsTrue(dep.IsDependency("${call2.request}")); Assert.IsFalse(dep.IsDependency("${ANY}")); Assert.IsFalse(dep.IsDependency("${NUMBER}")); }
public async Task Replace(RequestConfig requestConfig) { if (_dependencyDetector.IsDependency(requestConfig.Url)) { string name = _dependencyDetector.GetDependencyName(requestConfig.Url); if (_dict.TryGetValue(name, out var result)) { var valueToReplace = _dependencyDetector.Evaluate(requestConfig.Url, await result); requestConfig.Url = Regex.Replace(requestConfig.Url, @"\$\{.*\}", valueToReplace); } } }
public async Task ReplaceDependecy(JsonObject jsonObject) { foreach (var item in jsonObject.Keys) { var jsonItem = jsonObject[item]; if (jsonItem is JsonObject) { await ReplaceDependecy(jsonItem as JsonObject); } if (jsonItem is JsonString) { var value = jsonItem.GetValue().ToString(); if (_dependencyDetector.IsDependency(value)) { string name = _dependencyDetector.GetDependencyName(value); if (_dict.TryGetValue(name, out var result)) { var valueToReplace = _dependencyDetector.Evaluate(value, await result); (jsonItem as JsonString).Value = valueToReplace; } } } } }