src/SFBulkAPIStarterTest/TestBulkApiClient.cs
/// <summary>
/// Tests querying an account after an account is inserted.
/// </summary>
Tests querying an account after an account is inserted.
Tests querying an account after an account is inserted .
[TestMethod]
        public void QueryAccountTest()
        {
            CreateJobRequest insertAccountJobRequest = buildDefaultInsertAccountCreateJobRequest();
            Job insertAccountJob = _apiClient.CreateJob(insertAccountJobRequest);
            String batchContents = buildDefaultAccountBatchContents();
            CreateBatchRequest batchRequest = buildCreateBatchRequest(insertAccountJob.Id, batchContents);
            Batch accountBatch = _apiClient.CreateBatch(batchRequest);
            _apiClient.CloseJob(insertAccountJob.Id);
            insertAccountJob = _apiClient.GetCompletedJob(insertAccountJob.Id);
            CreateJobRequest queryAccountJobRequest = buildDefaultQueryAccountCreateJobRequest();
            Job queryJob = _apiClient.CreateJob(queryAccountJobRequest);
            String accountQuery = "SELECT Id, Name FROM Account WHERE Name = '" + DEFAULT_ACCOUNT_NAME + "'";
            CreateBatchRequest queryBatchRequest = buildCreateBatchRequest(queryJob.Id, accountQuery);
            queryBatchRequest.BatchContentType = BatchContentType.CSV;
            Batch queryBatch = _apiClient.CreateBatch(queryBatchRequest);
            _apiClient.CloseJob(queryJob.Id);
            queryJob = _apiClient.GetCompletedJob(queryJob.Id);
            String batchQueryResultsList = _apiClient.GetBatchResults(queryBatch.JobId, queryBatch.Id);
            List<String> resultIds = _apiClient.GetResultIds(batchQueryResultsList);
            Assert.AreEqual(1, resultIds.Count);
            String batchQueryResults = _apiClient.GetBatchResult(queryBatch.JobId, queryBatch.Id, resultIds[0]);
            Assert.IsTrue(batchQueryResults.Contains(DEFAULT_ACCOUNT_NAME));
        }
[ TestMethod ] public void QueryAccountTest ( ) { CreateJobRequest insertAccountJobRequest = buildDefaultInsertAccountCreateJobRequest ( ) ; Job insertAccountJob = _apiClient . CreateJob ( insertAccountJobRequest ) ; String batchContents = buildDefaultAccountBatchContents ( ) ; CreateBatchRequest batchRequest = buildCreateBatchRequest ( insertAccountJob . Id , batchContents ) ; Batch accountBatch = _apiClient . CreateBatch ( batchRequest ) ; _apiClient . CloseJob ( insertAccountJob . Id ) ; insertAccountJob = _apiClient . GetCompletedJob ( insertAccountJob . Id ) ; CreateJobRequest queryAccountJobRequest = buildDefaultQueryAccountCreateJobRequest ( ) ; Job queryJob = _apiClient . CreateJob ( queryAccountJobRequest ) ; String accountQuery = " " + DEFAULT_ACCOUNT_NAME + " " ; CreateBatchRequest queryBatchRequest = buildCreateBatchRequest ( queryJob . Id , accountQuery ) ; queryBatchRequest . BatchContentType = BatchContentType . CSV ; Batch queryBatch = _apiClient . CreateBatch ( queryBatchRequest ) ; _apiClient . CloseJob ( queryJob . Id ) ; queryJob = _apiClient . GetCompletedJob ( queryJob . Id ) ; String batchQueryResultsList = _apiClient . GetBatchResults ( queryBatch . JobId , queryBatch . Id ) ; List < String > resultIds = _apiClient . GetResultIds ( batchQueryResultsList ) ; Assert . AreEqual ( 1 , resultIds . Count ) ; String batchQueryResults = _apiClient . GetBatchResult ( queryBatch . JobId , queryBatch . Id , resultIds [ 0 ] ) ; Assert . IsTrue ( batchQueryResults . Contains ( DEFAULT_ACCOUNT_NAME ) ) ; }
Tests querying an account after an account is inserted.
Tests querying an account after an account is inserted .
// Insert an account so there's at least one to query // Query the account that was inserted.