====================================================== After help I was able to get this solved:
Test Class:
@isTest
public class TestUploadCSVController {
static testmethod void testfileupload1(){
String OUTPUT_DOCUMENT_NAME = 'Test File.csv';
String body = 'LastName,FirstName,Company,Title,LeadSource,Email, STORE_Verified__c, Targeted__c, Description\n '+
'me,Test,Test Company ,CEO,Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.\n' +
'you,Test,Test Company ,CIO,Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.\n' +
'Us,Test,Test Company ,CTO,Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.\n' +
'tester5,Test,Test Company ,CXO,Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.\n' +
'tester1,Test,Test Company ,COO,Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.\n' +
'tester2,Test,Test Company ,CSO,Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.\n' +
'tester3,Test,Test Company ,"Vp, Technology",Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.\n' +
'tester4,Test,Test Company ,"VP, Clicent Success",Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.';
Blob fileBody = Blob.valueOf(body);
//set current page to vf
PageReference PageReference = Page.UploadCSVControllerPage;
test.setCurrentPage(PageReference);
//pass in id from blob to idInputFile
UploadCSVController controllerInstance = new UploadCSVController();
// Then call the instance method
controllerInstance.fileBody = filebody;
controllerInstance.fileSize = 502;
controllerInstance.fileName = OUTPUT_DOCUMENT_NAME;
controllerInstance.ReadFromFile();
controllerInstance.save();
}
static testmethod void testfileupload2(){
String OUTPUT_DOCUMENT_NAME = 'Test File.xls';
String body = 'LastName,FirstName,Company,Title,LeadSource,Email, STORE_Verified__c, Targeted__c, Description\n '+
'me,Test,Test Company ,CEO,Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.\n' +
'you,Test,Test Company ,CIO,Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.\n' +
'Us,Test,Test Company ,CTO,Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.\n' +
'tester5,Test,Test Company ,CXO,Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.\n' +
'tester1,Test,Test Company ,COO,Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.\n' +
'tester2,Test,Test Company ,CSO,Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.\n' +
'tester3,Test,Test Company ,"Vp, Technology",Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.\n' +
'tester4,Test,Test Company ,"VP, Clicent Success",Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.';
Blob fileBody = Blob.valueOf(body);
//set current page to vf
PageReference PageReference = Page.UploadCSVControllerPage;
test.setCurrentPage(PageReference);
//pass in id from blob to idInputFile
UploadCSVController controllerInstance = new UploadCSVController();
// Then call the instance method
controllerInstance.fileBody = filebody;
controllerInstance.fileSize = 502;
controllerInstance.fileName = OUTPUT_DOCUMENT_NAME;
controllerInstance.ReadFromFile();
}
static testmethod void testfileupload3(){
String OUTPUT_DOCUMENT_NAME = 'Test File.csv';
String body = 'LastName,FirstName,Company,Title,LeadSource,Email, STORE_Verified__c, Targeted__c, Description\n '+
'me,Test,Test Company ,CEO,Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.\n' +
'you,Test,Test Company ,CIO,Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.\n' +
'Us,Test,Test Company ,CTO,Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.\n' +
'tester5,Test,Test Company ,CXO,Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.\n' +
'tester1,Test,Test Company ,COO,Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.\n' +
'tester2,Test,Test Company ,CSO,Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.\n' +
'tester3,Test,Test Company ,"Vp, Technology",Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.\n' +
'tester4,Test,Test Company ,"VP, Clicent Success",Other,[email protected],TRUE, 12/01/2022, This is a long text description. Please take a look and then tell us if this has passed.';
Blob fileBody = Blob.valueOf(body);
//set current page to vf
PageReference PageReference = Page.UploadCSVControllerPage;
test.setCurrentPage(PageReference);
//pass in id from blob to idInputFile
UploadCSVController controllerInstance = new UploadCSVController();
// Then call the instance method
controllerInstance.fileBody = filebody;
controllerInstance.fileSize = 502;
controllerInstance.fileName = OUTPUT_DOCUMENT_NAME;
controllerInstance.ReadFromFile();
controllerInstance.save();
}
}