public void BatchSmokeTestWhereRequestUriIsNotRelativeToService() { Run(request => { request.HttpMethod = "POST"; request.RequestUriString = "NotBatchAtAll"; request.RequestHeaders["MyCustomRequestUri"] = "http://myservicebase/path1/path2/$batch"; request.RequestHeaders["MyCustomServiceUri"] = "http://myservicebase/path1/path2/"; var batch = new BatchWebRequest(); var innerRequest = new InMemoryWebRequest(); innerRequest.RequestUriString = "SomethingThatWillNotBeUsedAtAll"; innerRequest.RequestHeaders["MyCustomRequestUri"] = "http://myservicebase/path2/Customers(0)"; batch.Parts.Add(innerRequest); batch.SetContentTypeAndRequestStream(request); TestUtil.RunCatching(request.SendRequest); Assert.AreEqual(202, request.ResponseStatusCode); batch.ParseResponseFromRequest(request, true); Assert.AreEqual(400, innerRequest.ResponseStatusCode); var innerPayload = innerRequest.GetResponseStreamAsXDocument(); UnitTestsUtil.VerifyXPathExists(innerPayload, "adsm:error/adsm:message[text()=\"The URI 'http://myservicebase/path2/Customers(0)' is not valid because it is not based on 'http://myservicebase/path1/path2/'.\"]"); }); }
private static void RunBatchTest(TestWebRequest request, Action <TestWebRequest> configureBatchRequest, Action <TestWebRequest> configureInnerRequest, string innerRequestXPath) { request.HttpMethod = "POST"; var batch = new BatchWebRequest(); var innerRequest = new InMemoryWebRequest(); innerRequest.Accept = "application/atom+xml,application/xml"; configureBatchRequest(request); configureInnerRequest(innerRequest); batch.Parts.Add(innerRequest); batch.SetContentTypeAndRequestStream(request); TestUtil.RunCatching(request.SendRequest); Assert.AreEqual(202, request.ResponseStatusCode); batch.ParseResponseFromRequest(request, true); Assert.AreEqual(200, innerRequest.ResponseStatusCode); var innerPayload = innerRequest.GetResponseStreamAsXDocument(); UnitTestsUtil.VerifyXPathExists(innerPayload, innerRequestXPath); }