You need to sign in to do that
Don't have an account?

test code for Attachment
Hi all,
hoe to write the code coverage for the following lines,
private void getAttachmentInfo(){
listAttachments = [SELECT ParentId , Name, BodyLength, Id, CreatedDate FROM Attachment WHERE ParentId = :taskid
ORDER BY CreatedDate DESC LIMIT 50 ];
for(Attachment a : listAttachments) {
String size = null;
if(1048576 < a.BodyLength){
// Size greater than 1MB
size = '' + (a.BodyLength / 1048576) + ' MB';
}
else if(1024 < a.BodyLength){
// Size greater than 1KB
size = '' + (a.BodyLength / 1024) + ' KB';
}
else{
size = '' + a.BodyLength + ' bytes';
}
mapAttachmentSize.put(a.id, size);
}
}
hoe to write the code coverage for the following lines,
private void getAttachmentInfo(){
listAttachments = [SELECT ParentId , Name, BodyLength, Id, CreatedDate FROM Attachment WHERE ParentId = :taskid
ORDER BY CreatedDate DESC LIMIT 50 ];
for(Attachment a : listAttachments) {
String size = null;
if(1048576 < a.BodyLength){
// Size greater than 1MB
size = '' + (a.BodyLength / 1048576) + ' MB';
}
else if(1024 < a.BodyLength){
// Size greater than 1KB
size = '' + (a.BodyLength / 1024) + ' KB';
}
else{
size = '' + a.BodyLength + ' bytes';
}
mapAttachmentSize.put(a.id, size);
}
}