Created
October 5, 2015 11:35
-
-
Save andriybuday/3c084106811b220c8a74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Microsoft.VisualStudio.TestTools.WebTesting; | |
namespace YourAppLoadTesting | |
{ | |
public class AddCorrelationIdToReportPutRequest: WebTestPlugin | |
{ | |
public string ApplyToRequestsThatContain { get; set; } | |
public string BodyStringParam { get; set; } | |
public override void PreRequest(object sender, PreRequestEventArgs e) | |
{ | |
if (e.Request.Url.Contains(ApplyToRequestsThatContain) && e.Request.Method == "PUT") | |
{ | |
var requestBody = new StringHttpBody(); | |
requestBody.ContentType = "application/json; charset=utf-8"; | |
requestBody.InsertByteOrderMark = false; | |
requestBody.BodyString = e.WebTest.Context[BodyStringParam].ToString().Replace("\"correlationId\":null", | |
string.Format("\"correlationId\":\"{0}\\\\0\"", Guid.NewGuid())); | |
e.Request.Body = requestBody; | |
} | |
base.PreRequest(sender, e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment