10 Antworten
Update Method would be something llike, please note that i dont have the structure of your custom object so you will have to create that record first static testMethod void testUpdateAttachment()
{
Test.startTest();
//Custom object record insert
Blob b = Blob.valueOf('test data');
Attachment attachment = new Attachment();
//objectid is id of the record in which you want to create attachment, it could be a test account etc attachment.ParentId = objectId;
attachment.Name = 'Test Attachment for Parent';
attachment.Body = b;
insert(attachment);
Attachment at = [Select Id, Body, Name, ParentId from Attachment where ParentId =: objectId];
Blob b2 = Blob.valueOf('test 2 data');
at.body = b2;
update b2;
Test.stopTest();
}
Hope this helps