@isTest
private class CampaignRelationshipControllerTest {
    static testMethod void testMethod1() {
    	List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
    	List<RecordType> rectRVI = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer RVI'];
    	List<RecordType> rectNDT = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer NDT'];
    	List<RecordType> rectANI = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer ANI'];
        Campaign campain = new Campaign();
        campain.Name = '测试市场活动';

        insert campain;
        List<Account> insertAccountList = new List<Account>();
        Account accIE = new Account(
            name = '*',
            RecordTypeId = rectIE[0].Id,
            OwnerId = UserInfo.getUserId(),
            DivisionName__c = 'Customer IE',
            FacilityName__c = 'abc',
            PostCode__c='000000'
        );
        //insert accIE;
        insertAccountList.add(accIE);

        Account accRVI = new Account(
            name = '*',
            RecordTypeId = rectRVI[0].Id,
            OwnerId = UserInfo.getUserId(),
            DivisionName__c = 'Customer RVI',
            FacilityName__c = 'abc',
            PostCode__c='000000'
        );
        //insert accRVI;
         insertAccountList.add(accRVI);
        Account accNDT = new Account(
            name = '*',
            RecordTypeId = rectNDT[0].Id,
            OwnerId = UserInfo.getUserId(),
            DivisionName__c = 'Customer NDT',
            FacilityName__c = 'abc',
            PostCode__c='000000'
        );
        //insert accNDT;
        insertAccountList.add(accNDT);
        Account accANI = new Account(
            name = '*',
            RecordTypeId = rectANI[0].Id,
            OwnerId = UserInfo.getUserId(),
            DivisionName__c = 'Customer ANI',
            FacilityName__c = 'abc',
            PostCode__c='000000'
        );
        //insert accANI;
        insertAccountList.add(accANI);
        insert insertAccountList;

        List<CampaignRelationship__c> relationshipList = new List<CampaignRelationship__c>();
        CampaignRelationship__c r1 = new CampaignRelationship__c();
        r1.RelationshipAccount__c = accIE.id;
        r1.RelationshipCampaign__c = campain.Id;
        relationshipList.add(r1);

        CampaignRelationship__c r2 = new CampaignRelationship__c();
        r2.RelationshipAccount__c = accRVI.id;
        r2.RelationshipCampaign__c = campain.Id;
        relationshipList.add(r2);

        CampaignRelationship__c r3 = new CampaignRelationship__c();
        r3.RelationshipAccount__c = accNDT.id;
        r3.RelationshipCampaign__c = campain.Id;
        relationshipList.add(r3);

        CampaignRelationship__c r4 = new CampaignRelationship__c();
        r4.RelationshipAccount__c = accANI.id;
        r4.RelationshipCampaign__c = campain.Id;
        relationshipList.add(r4);


        insert relationshipList;
        PageReference page = new PageReference('/apex/CampaignRelationship?campaignId='+campain.Id);
        System.Test.setCurrentPage(page);
        CampaignRelationshipController controller = new CampaignRelationshipController();
        controller.init(); 

        controller = new CampaignRelationshipController(new ApexPages.StandardController(campain));
        controller.init();
        controller.DataLoadAccount(); 


    }
}