src/SFBulkAPIStarterTest/TestBulkApiClient.cs
/// <summary>
/// Tests attaching a file to the specified "AttachmentParentId" record.
/// </summary>
Tests attaching a file to the specified "AttachmentParentId" record.
Tests attaching a file to the specified " AttachmentParentId " record .
[TestMethod]
        public void AttachFileTest()
        {
            String parentId = ConfigurationManager.AppSettings["AttachmentParentId"];
            Assert.IsTrue(String.IsNullOrWhiteSpace(parentId) == false, "The AttachmentParentId app setting is blank. Please specify the id of a salesforce record to attach an attachment file.");
            CreateJobRequest attachmentJobRequest = buildDefaultAttachmentJobRequest();
            Job attachmentJob = _apiClient.CreateJob(attachmentJobRequest);
            String filename = "BulkAPIClientAttachment.txt";
            File.WriteAllText(filename, "Hello From Attach File Test");
            CreateAttachmentBatchRequest attachmentBatchRequest = new CreateAttachmentBatchRequest();
            attachmentBatchRequest.FilePath = filename;
            attachmentBatchRequest.JobId = attachmentJob.Id;
            attachmentBatchRequest.ParentId = parentId;
            Batch attachmentBatch = _apiClient.CreateAttachmentBatch(attachmentBatchRequest);
            _apiClient.CloseJob(attachmentJob.Id);
            attachmentJob = _apiClient.GetCompletedJob(attachmentJob.Id);
            Assert.AreEqual(1, attachmentJob.NumberRecordsProcessed, "The file was not attached to the specified record.");
        }
[ TestMethod ] public void AttachFileTest ( ) { String parentId = ConfigurationManager . AppSettings [ " " ] ; Assert . IsTrue ( String . IsNullOrWhiteSpace ( parentId ) == false , " " ) ; CreateJobRequest attachmentJobRequest = buildDefaultAttachmentJobRequest ( ) ; Job attachmentJob = _apiClient . CreateJob ( attachmentJobRequest ) ; String filename = " " ; File . WriteAllText ( filename , " " ) ; CreateAttachmentBatchRequest attachmentBatchRequest = new CreateAttachmentBatchRequest ( ) ; attachmentBatchRequest . FilePath = filename ; attachmentBatchRequest . JobId = attachmentJob . Id ; attachmentBatchRequest . ParentId = parentId ; Batch attachmentBatch = _apiClient . CreateAttachmentBatch ( attachmentBatchRequest ) ; _apiClient . CloseJob ( attachmentJob . Id ) ; attachmentJob = _apiClient . GetCompletedJob ( attachmentJob . Id ) ; Assert . AreEqual ( 1 , attachmentJob . NumberRecordsProcessed , " " ) ; }
Tests attaching a file to the specified "AttachmentParentId" record.
Tests attaching a file to the specified " AttachmentParentId " record .
// Create Attachment Job // Create file to attach to record // Create attachment batch request // Create attachment batch // Close job so no more batches are added.