@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();
    }
}