@isTest(SeeAllData=true)
private class TestAttachment{
static testmethod void testattach(){
Account a = new Account(Name='newAcct');
Test.startTest();
insert a;
Test.stopTest();
System.debug('Account created: ' + a.Id);
Attachment attach=new Attachment();
attach.Name='Unit Test Attachment';
Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
attach.body=bodyBlob;
attach.parentId=a.Id;
attach.ContentType = 'application/msword';
attach.IsPrivate = false;
attach.Description = 'Test';
insert attach;
System.debug('Inserted: '+ attach.Id);
List<Account> acct = [SELECT id, Name,
(SELECT Id FROM CombinedAttachments)
FROM Account where id = :a.Id];
System.debug('Account Query : '+acct);
for(Account a1 : acct){
System.debug('Id: '+a1.Id + ' Name: '+a1.Name + ' CombAttach: '+ a1.CombinedAttachments);
System.assert(a1.CombinedAttachments.size()>0);
}
}
}
cheers!
Nice Blog, Very Informative Content,waiting for next update...
ReplyDeletecore java training in chennai
core java classes
core java training in chennai
core java Training in OMR
core java training in Porur
C C++ Training in Chennai
javascript training in chennai
Hibernate Training in Chennai
Very helpful blog for us. Thanks for sharing. Please checkSalesforce Training
ReplyDeleteFor Administrators & Developers Salesforce Developer Certification