public void BatchTest() { Mock <IOrganizationService> orgSvc = null; Mock <MoqHttpMessagehander> fakHttpMethodHander = null; CdsServiceClient cli = null; testSupport.SetupMockAndSupport(out orgSvc, out fakHttpMethodHander, out cli); CreateResponse createResponse = new CreateResponse(); createResponse.Results = new ParameterCollection(); createResponse.Results.Add("annotationid", testSupport._DefaultId); ExecuteMultipleResponseItem responseItem = new ExecuteMultipleResponseItem(); responseItem.Response = createResponse; responseItem.RequestIndex = 0; ExecuteMultipleResponseItemCollection responseItems = new ExecuteMultipleResponseItemCollection(); responseItems.Add(responseItem); ExecuteMultipleResponse executeMultipleResponse = new ExecuteMultipleResponse(); executeMultipleResponse.Results = new ParameterCollection(); executeMultipleResponse.Results.Add("Responses", responseItems); orgSvc.Setup(req1 => req1.Execute(It.IsAny <ExecuteMultipleRequest>())).Returns(executeMultipleResponse); // Setup a batch string BatchRequestName = "TestBatch"; Guid batchid = cli.CreateBatchOperationRequest(BatchRequestName); // use create operation to setup request Dictionary <string, CdsDataTypeWrapper> newFields = new Dictionary <string, CdsDataTypeWrapper>(); newFields.Add("name", new CdsDataTypeWrapper("CrudTestAccount", CdsFieldType.String)); newFields.Add("accountnumber", new CdsDataTypeWrapper("12345", CdsFieldType.String)); newFields.Add("telephone1", new CdsDataTypeWrapper("555-555-5555", CdsFieldType.String)); newFields.Add("donotpostalmail", new CdsDataTypeWrapper(true, CdsFieldType.Boolean)); // issue request as a batch: Guid result = cli.CreateAnnotation("account", testSupport._DefaultId, newFields, batchid); Assert.Equal <Guid>(Guid.Empty, result); OrganizationRequest req = cli.GetBatchRequestAtPosition(batchid, 0); // Executes the batch request. cli.ExecuteBatch(batchid); // Request Batch by name Guid OperationId = cli.GetBatchOperationIdRequestByName(BatchRequestName); // Request batch back RequestBatch reqBatch = cli.GetBatchById(batchid); Assert.NotNull(reqBatch); Assert.Equal(BatchRequestName, reqBatch.BatchName); Assert.True(reqBatch.BatchItems.Count == 1); // Release batch request cli.ReleaseBatchInfoById(batchid); }