彭锟
2022-04-01 216f61fcfdd0bc469cec809c31e4d49c1d86158e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
@isTest
private class AccountVisitCountControllerTest {
 
    static testMethod void myUnitTest() {
        // データ作成
        RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        Account hospital = new Account();
        hospital.RecordTypeId = rectCo.Id;
        hospital.Name         = 'TestHospital';
        insert hospital;
 
        PageReference page = new PageReference('/apex/AccountVisitCount?id=' + hospital.Id);
        System.Test.setCurrentPage(page);
        AccountVisitCountController controller = new AccountVisitCountController(new ApexPages.StandardController(hospital));
        Account2__c acc2 = [Select Id, Account_Org__c from Account2__c where Account_Org__c = :hospital.Id];
        System.assertEquals(acc2.Id, controller.acc2.Id);
    }
}