private void GetResponse(string uri, string responseFormat, Type contextType, string[] xPathsToVerify, KeyValuePair <string, string>[] headerValues, string httpMethodName, string requestPayload) { using (TestWebRequest request = TestWebRequest.CreateForInProcess()) { request.DataServiceType = contextType; request.RequestUriString = uri; request.Accept = responseFormat; request.HttpMethod = httpMethodName; UnitTestsUtil.SetHeaderValues(request, headerValues); if (requestPayload != null) { request.RequestContentType = responseFormat; request.RequestStream = new MemoryStream(); StreamWriter writer = new StreamWriter(request.RequestStream); writer.Write(requestPayload); writer.Flush(); } request.SendRequest(); Stream responseStream = request.GetResponseStream(); if (xPathsToVerify != null) { UnitTestsUtil.VerifyXPaths(responseStream, responseFormat, xPathsToVerify); } } }