I am trying to write a test class for a simple Apex Class which sets the status of the Case to be Closed like below
public class updateCaseRecord {
@AuraEnabled
public static void updateCheck(String caseId){
List<Case> records = [select id,Status from Case WHERE Id = :caseId];
for (Case record : records)
{
record.Status = 'Closed';
}
update records;
}
}
The test class I have written so far is like below I have created a test account,contact and a case.
@IsTest
public class updateCaseRecordTest {
@IsTest(SeeAllData=true) static void testIsUpdateCheck() {
ID parentRecType = '012U0000000PqA9IAK';
ID csRecType = '012U0000000QGv4IAG';
Account pa = new Account(Name='Test Parent Account', recordTypeId=parentRecType);
insert pa;
Account testAccount = new Account(Name='test', Industry='Biotech',Territory__c='EUR',BillingCity='Test',BillingCountry='Germany',ParentId=pa.id);
insert testAccount;
Contact c = new Contact(LastName='Test',LeadSource='Customer Service',AccountId=testAccount.Id);
insert c;
Case newCase = new Case();
newCase.Subject = 'testStatusClosed';
newCase.Status = 'New';
newCase.Category__c = 'Inquiry';
newCase.Sub_Category__c = 'Other';
newCase.AccountId = testAccount.Id;
newCase.ContactId = c.id;
newCase.recordTypeId=csRecType;
insert newCase;
ApexPages.standardController std = New ApexPages.standardController(newCase);
updateCaseRecord uC = new updateCaseRecord();
uC.updateCheck(std);
}}
I get the error like Method does not exist or incorrect signature: void updateCheck(ApexPages.StandardController) from the type updateCaseRecord
. How can I test the apex class and can have the assertion statement. I am writing first time test scripts and I am kind of lost. Any help is greatly appreciated