You need to sign in to do that
Don't have an account?
simon chao
bulk test class inquiry
I have written the below controller class. Was wondering how to write a bulk test for it. any suggestions? Are there good guides out there that teaches how to write test class? Besides for the trailhead module?
public with sharing class newStudent { @AuraEnabled public static Contact getStudent(Id stuId) { Contact stu = [ SELECT Id, Name, Gender__c, School__c ( SELECT class_id__c, class_teacher__r.Name, class_subject__c FROM class__r ) FROM Contact WHERE Id =: stuId ]; return stu; } //https://developer.salesforce.com/blogs/developer-relations/2015/11/create-lightning-component-drag-drop-profile-pictures.html @AuraEnabled public static Attachment studentPicture (Id stuId) { if (!Schema.sObjectType.Contact.isAccessible()) { throw new System.NoAccessException(); } List<Attachment> lAttachment = new List<Attachment>( [ SELECT Id, Name, LastModifiedDate, ContentType FROM Attachment WHERE parentid=:stuId AND ContentType IN ('image/png', 'image/jpeg', 'image/gif') ORDER BY LastModifiedDate DESC LIMIT 1 ] ); return lAttachment.size() > 0 ? lAttachment[0] : null; } @AuraEnabled public static Id saveAttachment(Id parentId, String fileName, String base64Data, String contentType) { if (!Schema.sObjectType.Contact.isUpdateable()) { throw new System.NoAccessException(); } Attachment attachment = new Attachment(); attachment.parentId = parentId; attachment.body = EncodingUtil.base64Decode(base64Data); attachment.name = fileName; attachment.contentType = contentType; insert attachment; return attachment.id; } }
All Answers