@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
JavaScript training helps learners build the skills needed to create interactive and dynamic websites. A well-structured training program covers the fundamentals of JavaScript, including variables, data types, operators, loops, functions, arrays, objects, and events. As learners progress, they gain hands-on experience with DOM manipulation, form validation, asynchronous programming, and modern ES6+ features, enabling them to develop responsive and user-friendly web applications.
ReplyDeleteMany JavaScript training programs are powered by Blogger to provide easy access to tutorials, coding exercises, project updates, and learning resources. TypeScript TrainingBlogger offers a simple platform where instructors can publish lessons, share sample code, and communicate with students through regular posts. By combining practical projects with online learning materials, JavaScript training powered by Blogger creates an accessible and effective environment for beginners and aspiring web developers.
ReplyDelete