public override void PostRequest(object sender, PostRequestEventArgs e) { WebTestRequestCollection depsToRemove = new WebTestRequestCollection(); // Note, you can't modify the collection inside a foreach, hence the second collection // requests to remove. foreach (WebTestRequest r in e.Request.DependentRequests) { if (!string.IsNullOrEmpty(FilterDependentRequestsThatStartWith)) { if (r.Url.StartsWith(FilterDependentRequestsThatStartWith)) { depsToRemove.Add(r); } } else if (!string.IsNullOrEmpty(FilterDependentRequestsThatEndWith)) { if (r.Url.EndsWith(FilterDependentRequestsThatEndWith)) { depsToRemove.Add(r); } } } foreach (WebTestRequest r in depsToRemove) { e.WebTest.AddCommentToResult(string.Format("Removing dependent: {0}", r.Url)); e.Request.DependentRequests.Remove(r); } }
public override void PostRequest(object sender, PostRequestEventArgs e) { WebTestRequestCollection depsToRemove = new WebTestRequestCollection(); // Note, you can't modify the collection inside a foreach, hence the second collection // requests to remove. foreach (WebTestRequest r in e.Request.DependentRequests) { if (!string.IsNullOrEmpty(FilterDependentRequestsThatStartWith) && r.Url.StartsWith(FilterDependentRequestsThatStartWith)) { depsToRemove.Add(r); } if (!string.IsNullOrEmpty(FilterDependentRequestsThatEndWith) && r.Url.EndsWith(FilterDependentRequestsThatEndWith)) { depsToRemove.Add(r); } if (!string.IsNullOrEmpty(FilterDependentRequestsThatContain) && r.Url.Contains(FilterDependentRequestsThatContain)) { depsToRemove.Add(r); } } foreach (WebTestRequest r in depsToRemove) { e.Request.DependentRequests.Remove(r); } WebTestDependentFilter DepFilter = new WebTestDependentFilter(); DepFilter.FilterDependentRequestsThatContain = FilterDependentRequestsThatContain; DepFilter.FilterDependentRequestsThatEndWith = FilterDependentRequestsThatEndWith; DepFilter.FilterDependentRequestsThatStartWith = FilterDependentRequestsThatStartWith; foreach (WebTestRequest r in e.Request.DependentRequests) { r.PreRequest += new EventHandler <PreRequestEventArgs>(DepFilter.PreRequest); r.PostRequest += new EventHandler <PostRequestEventArgs>(DepFilter.PostRequest); } }
public override void PreRequest(object sender, PreRequestEventArgs e) { WebTestRequestCollection depsToRemove = new WebTestRequestCollection(); var y = e.Request; foreach (WebTestRequest r in e.Request.DependentRequests) { if (!string.IsNullOrEmpty(FilterDependentRequestsThatStartWith) && r.Url.Contains(FilterDependentRequestsThatStartWith)) { depsToRemove.Add(r); } else { var x = r; } } foreach (WebTestRequest r in depsToRemove) { e.Request.DependentRequests.Remove(r); } }