@isTest
private class CampaignMemberEditDeleteControllerTest {

	@isTest static void testInit() {
		RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
		List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_GI', 'Department_BF') order by DeveloperName desc];

		Account acc = new Account();
		acc.RecordTypeId = rectCo.Id;
		acc.Name = 'HP test1';
		insert acc;

		List<Account> dept = [select Id, Name from Account where ParentId = :acc.Id and Department_Class_Label__c IN ('消化科', '呼吸科') order by Department_Class_Label__c];

		Account depart1 = new Account();
		depart1.RecordTypeId = rectDpt[0].Id;
		depart1.Name         = '*';
		depart1.Department_Name__c  = 'Gastoro Intestin Test';
		depart1.ParentId            = dept[0].Id;
		depart1.Department_Class__c = dept[0].Id;
		depart1.Hospital__c         = acc.Id;

		Account depart2 = new Account();
		depart2.RecordTypeId = rectDpt[1].Id;
		depart2.Name         = '*';
		depart2.Department_Name__c  = '診療科2';
		depart2.ParentId            = dept[1].Id;
		depart2.Department_Class__c = dept[1].Id;
		depart2.Hospital__c         = acc.Id;
		insert new Account[] {depart1, depart2};

		Contact con = new Contact();
		con.LastName = 'lastname2';
		con.FirstName = 'firstname2';
		con.Email = 'olympustest033@sunbridge.com';
		con.MobilePhone = '99999999';
		con.Work_Location_manual__c = 'location2';
		con.Post_picklist__c = '部长';
		con.Job_Category_picklist__c = '销售推广';
		con.Hire_date_text__c = Date.today().addMonths(-6);
		con.Gender_text__c = '男';
		con.dept__c = '服务本部';
		con.Pregnant_Rest__c = true;
		insert con;

		RecordType oppVND = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity'];

		Opportunity opp1 = new Opportunity(
		    Name = 'test opp1',
		    StageName = '引合',
		    CurrencyIsoCode = 'USD',
		    CloseDate = Date.today(),
		    AccountId = depart1.Id,
		    RecordTypeId = oppVND.Id,
		    Closing_Bid_Date__c = Date.today().addDays(-5),
		    Hospital__c = acc.Id,
		    Competitor__c = 'A'
		);
		Opportunity opp2 = new Opportunity(
		    Name = 'test opp2',
		    StageName = '引合',
		    CurrencyIsoCode = 'USD',
		    CloseDate = Date.today(),
		    AccountId = depart2.Id,
		    RecordTypeId = oppVND.Id,
		    Closing_Bid_Date__c = Date.today().addDays(-5),
		    Hospital__c = acc.Id,
		    Competitor__c = 'B'
		);
		insert new Opportunity[] {opp1, opp2};
		RecordType recTCam = [select Id from RecordType where IsActive = true and SobjectType = 'Campaign' and DeveloperName = 'ServiceEngineerTraining'];
		Campaign cam = new Campaign();
		cam.RecordTypeid = recTCam.id;
		cam.Name = 'cam';

		insert cam;
		PageReference page = new PageReference('/apex/CampaignMemberEditAndDelete?retURL=' + cam.Id);
		System.Test.setCurrentPage(page);
		CampaignMemberEditAndDeleteController controller = new CampaignMemberEditAndDeleteController();
		controller.init();

	}

}