You need to sign in to do that
Don't have an account?
Simon234
What kind of test can I write to check the file?
Hello. I have a controller for VF Page. This code upload a profile's image (we can see it after that) and delete it. What kind of test can help me to check this file? I need to know, is it uploaded or not.
I work with ContentVersion and ContentDocumentLink :
public class FileUploaderController { public ContentVersion conVer {get; set;} public ContentDocumentLink conDocLink {get; set;} public Candidate__c thisCandidate{get; set;} public FileUploaderController(ApexPages.StandardController controller){ thisCandidate = (Candidate__c)controller.getRecord(); conVer = new ContentVersion(); } public PageReference uploadFile() { List<ContentVersion> conVerList = new List<ContentVersion>(); List<ContentDocumentLink> conDocLinkList = new List<ContentDocumentLink>(); if (conVer.VersionData == null) { conVer.VersionData = null; return null; } conVerList.add(conVer); insert conVerList; thisCandidate.Photo__c = conVer.Id; update thisCandidate; if (conVer.ContentDocumentId == null) { Id conDoc = [SELECT ContentDocumentId FROM ContentVersion WHERE Id =: conVer.Id].ContentDocumentId; conDocLink = new ContentDocumentLink( LinkedEntityId = thisCandidate.Id, ContentDocumentId = conDoc, ShareType = 'I' ); conDocLinkList.add(conDocLink); insert conDocLinkList; } conVer.VersionData = null; return null; } public PageReference deleteFile() { thisCandidate.Photo__c = null; update thisCandidate; conVer = new ContentVersion(); return null; } }
Best Answer chosen by Simon234
Raj Vakati
Pls use this test class