I am drafting up a couple of unit tests for this code.
Here is what the code looks like so far:
public class ContentController {
public ContentController() {
file = new ContentVersion();
}
public ContentVersion file { get; set; }
public PageReference go() {
insert file;
return new PageReference('**url**');
}
}
The initial unit test for testing just a file upload for this code is drafted up as such:
@isTest
private class BestDoctorsTest{
@isTest
private static void testUpload(){
ContentController controller = new ContentController();
controller.file.Body = Blob.valueOf('populated');
PageReference redirect = controller.go();
system.assertEquals(1, [SELECT count() FROM ContentVersion]);
}
}
Given how Blobs work and the functionality of ContentVersions this should work fine. However, apex returns this error:
How to I correctly obtain the body of a ContentVersion?