buli
2022-05-14 ead4df22dca33a867279471821ca675f91dec760
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
@isTest
private class TS_SearchAccountControllerTest {
 
    public static Account account;
    static void basicData() {
        List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
        account = new Account(
            name = 'Test20200827',
            RecordTypeId = rectIE[0].Id,
            OwnerId = UserInfo.getUserId(),
            DivisionName__c = 'Customer IE',
            FacilityName__c = 'abc',
            DivisionName_D__c = 'Customer IE',
            FacilityNameD__c = 'abc',
            AccountStatus__c = 'Cancel',
            PostCode__c = '123456',
            ProductSegment__c = 'IE'
        );
 
        insert account;
    }
    // q 正常
    static testMethod void testMethod1() {
        basicData();
        PageReference page = new PageReference('/apex/TS_SearchAccount?q=Test20200827&r=' + account.ProductSegment__c);
        System.Test.setCurrentPage(page);
        TS_SearchAccountController controller = new TS_SearchAccountController();
        controller.search();
 
        controller.getIsOverLimit();
    }
    // q null
    static testMethod void testMethod2() {
        basicData();
        String reporterState = 'NDT/ANI';
        PageReference page = new PageReference('/apex/TS_SearchAccount?q=&r=' + reporterState);
        System.Test.setCurrentPage(page);
        TS_SearchAccountController controller = new TS_SearchAccountController();
        controller.search();
 
        controller.getIsOverLimit();
    }
    // q length < 3
    static testMethod void testMethod3() {
        basicData();
        String reporterState = 'System';
        PageReference page = new PageReference('/apex/TS_SearchAccount?q=::&r=' + reporterState);
        System.Test.setCurrentPage(page);
        TS_SearchAccountController controller = new TS_SearchAccountController();
        controller.search();
 
        controller.getIsOverLimit();
    }
}