@isTest
|
private class CampaignMeetingcostControllertest {
|
@Testsetup
|
static void init() {
|
// Implement test code
|
Campaign target1 = new Campaign();
|
target1.Name = 'test campaign1';
|
target1.Meeting_Type__c = '赞助会';
|
target1.HostName__c = '主办方';
|
target1.cooperatorCompany__c = '承办方';
|
target1.IsDocLOGO__c = true;
|
target1.IsDocLOGO__c = true;
|
target1.formality1__c = true;
|
target1.IsShowingEquipment__c = true;
|
target1.IsAnimalExperience__c = true;
|
target1.isOther__c = true;
|
string rec = Schema.SObjectType.Campaign.getRecordTypeInfosByDeveloperName().get('BusinessTraining').getRecordTypeId();
|
target1.RecordTypeId = rec;
|
|
Campaign target2 = new Campaign();
|
target2.Name = 'test campaign2';
|
target2.RecordTypeId = rec;
|
target2.Meeting_Type__c = '共同主办会';
|
target2.HostName__c = '主办方';
|
target2.cooperatorCompany__c = '承办方';
|
target2.IsSatelliteMeeting__c = true;
|
target2.formality1__c = true;
|
target2.isStand__c = true;
|
target2.isTitle__c = true;
|
insert new Campaign[] {target1, target2};
|
}
|
|
@isTest static void test_init() {
|
list<Campaign> CampaignList = [select id, Name from Campaign ];
|
Campaign target1 = CampaignList[0];
|
PageReference page1 = new PageReference('/apex/CampaignMeetingcost?id=' + target1.Id);
|
System.Test.setCurrentPage(page1);
|
CampaignMeetingcostController con1 = new CampaignMeetingcostController();
|
con1.init();
|
User tempUser = getUser();
|
system.runAs(tempUser) {
|
con1.init();
|
}
|
|
}
|
@isTest static void test_dummy() {
|
CampaignMeetingcostController con1 = new CampaignMeetingcostController();
|
con1.dummy();
|
}
|
|
@isTest static void test_save1() {
|
list<Campaign> CampaignList = [select id, Name from Campaign where Meeting_Type__c = '赞助会'];
|
Campaign target1 = CampaignList[0];
|
PageReference page1 = new PageReference('/apex/CampaignMeetingcost?id=' + target1.Id);
|
System.Test.setCurrentPage(page1);
|
CampaignMeetingcostController con1 = new CampaignMeetingcostController();
|
con1.init();
|
con1.save();
|
con1.submit();
|
}
|
|
@isTest static void test_save2() {
|
list<Campaign> CampaignList = [select id, Name from Campaign where Meeting_Type__c = '共同主办会'];
|
Campaign target1 = CampaignList[0];
|
PageReference page1 = new PageReference('/apex/CampaignMeetingcost?id=' + target1.Id);
|
System.Test.setCurrentPage(page1);
|
CampaignMeetingcostController con1 = new CampaignMeetingcostController();
|
con1.init();
|
con1.save();
|
con1.submit();
|
}
|
|
private static User getUser() {
|
String timenow = Datetime.now().format('yyyyMMddHHmmss');
|
User hpOwner = new User(Test_staff__c = true, LastName = 'TestMao', FirstName = 'TestMaoF',
|
Alias = 'hp', CommunityNickname = 'TestMao', Email = 'Test@sunbridge.com',
|
Username = 'Test' + timenow + '@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP',
|
TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = System.Label.ProfileId_SystemAdmin,
|
Dept__c = '医疗华北营业本部', Province__c = '北京');
|
insert hpOwner;
|
return hpOwner;
|
}
|
|
}
|