@isTest public class RentalEquipmentCreateConTest { static testMethod void unitTest01() { OPDPlan__c target1 = new OPDPlan__c(); target1.OPDType__c = '学会'; insert target1; List res = new List(); Rental_Equipment__c re1 = new Rental_Equipment__c(Name = 'GI-290镜子'); res.add(re1); Rental_Equipment__c re2 = new Rental_Equipment__c(Name = 'EU-ME2'); res.add(re2); Rental_Equipment__c re3 = new Rental_Equipment__c(Name = 'OTV-S190'); res.add(re3); Rental_Equipment__c re4 = new Rental_Equipment__c(Name = 'CV-170'); res.add(re4); Rental_Equipment__c re5 = new Rental_Equipment__c(Name = 'OTV-S300'); res.add(re5); insert res; Test.startTest(); RentalEquipmentCreateController ren = new RentalEquipmentCreateController(); ren.opdId = target1.Id; ren.getProds(); Map tempMap = new Map(); tempMap.put('GI-290镜子', '1'); tempMap.put('EU-ME2', '2'); ren.planProductMap = tempMap; ren.save(); Test.stopTest(); } static testMethod void unitTest04() { OPDPlan__c target1 = new OPDPlan__c(); target1.OPDType__c = '事件'; target1.NoOpp_Reason__c = 'HCP对应'; insert target1; Date t1 = Date.today(); Event e = new Event( StartDateTime = Datetime.newInstance(t1.year(), t1.month(), t1.day(), 9, 0, 0), EndDateTime = Datetime.newInstance(t1.year(), t1.month(), t1.day(), 10, 0, 0), Opd_Plan__c = target1.Id, noOpp_Reason__c = 'HCP对应' ); insert e; List res = new List(); Rental_Equipment__c re1 = new Rental_Equipment__c(Name = 'GI-290镜子'); res.add(re1); Rental_Equipment__c re2 = new Rental_Equipment__c(Name = 'EU-ME2'); res.add(re2); Rental_Equipment__c re3 = new Rental_Equipment__c(Name = 'OTV-S190'); res.add(re3); Rental_Equipment__c re4 = new Rental_Equipment__c(Name = 'CV-170'); res.add(re4); Rental_Equipment__c re5 = new Rental_Equipment__c(Name = 'OTV-S300'); res.add(re5); insert res; Test.startTest(); RentalEquipmentCreateController ren = new RentalEquipmentCreateController(); ren.opdId = target1.Id; ren.getProds(); Map tempMap = new Map(); tempMap.put('GI-290镜子', '1'); tempMap.put('EU-ME2', '2'); ren.planProductMap = tempMap; ren.save(); Test.stopTest(); } static testMethod void unitTest02() { Campaign target1 = new Campaign(); target1.Name = 'test campaign1'; target1.Meeting_Type__c = '赞助会'; target1.IsDocLOGO__c = true; target1.IsDocLOGO__c = true; target1.formality1__c = true; target1.IsShowingEquipment__c = true; target1.IsAnimalExperience__c = true; target1.cooperatorCompany__c = '测试'; target1.HostName__c = '测试'; target1.isOther__c = true; string rec = Schema.SObjectType.Campaign.getRecordTypeInfosByDeveloperName().get('BusinessTraining').getRecordTypeId(); target1.RecordTypeId = rec; insert target1; List res = new List(); Rental_Equipment__c re1 = new Rental_Equipment__c(Name = 'GI-290镜子'); res.add(re1); Rental_Equipment__c re2 = new Rental_Equipment__c(Name = 'EU-ME2'); res.add(re2); Rental_Equipment__c re3 = new Rental_Equipment__c(Name = 'OTV-S190'); res.add(re3); Rental_Equipment__c re4 = new Rental_Equipment__c(Name = 'CV-170'); res.add(re4); Rental_Equipment__c re5 = new Rental_Equipment__c(Name = 'OTV-S300'); res.add(re5); insert res; Test.startTest(); RentalEquipmentCreateController ren = new RentalEquipmentCreateController(); ren.campaignId = target1.Id; ren.getProds(); Map tempMap = new Map(); tempMap.put('GI-290镜子', '1'); tempMap.put('EU-ME2', '2'); ren.planProductMap = tempMap; ren.save(); Test.stopTest(); } static testMethod void unitTest03() { Campaign target1 = new Campaign(); target1.Name = 'test campaign1'; target1.Meeting_Type__c = '赞助会'; target1.IsDocLOGO__c = true; target1.IsDocLOGO__c = true; target1.formality1__c = true; target1.IsShowingEquipment__c = true; target1.IsAnimalExperience__c = true; target1.cooperatorCompany__c = '测试'; target1.HostName__c = '测试'; target1.isOther__c = true; string rec = Schema.SObjectType.Campaign.getRecordTypeInfosByDeveloperName().get('BusinessTraining').getRecordTypeId(); target1.RecordTypeId = rec; insert target1; Plan_Rental_Equipment__c plan1 = new Plan_Rental_Equipment__c(Campaign__c = target1.Id,Rental_Equipment__c = 'OTV-S300',Rental_Quantity__c = '3'); insert plan1; List res = new List(); Rental_Equipment__c re1 = new Rental_Equipment__c(Name = 'GI-290镜子'); res.add(re1); Rental_Equipment__c re2 = new Rental_Equipment__c(Name = 'EU-ME2'); res.add(re2); Rental_Equipment__c re3 = new Rental_Equipment__c(Name = 'OTV-S190'); res.add(re3); Rental_Equipment__c re4 = new Rental_Equipment__c(Name = 'CV-170'); res.add(re4); Rental_Equipment__c re5 = new Rental_Equipment__c(Name = 'OTV-S300'); res.add(re5); insert res; Test.startTest(); RentalEquipmentCreateController ren = new RentalEquipmentCreateController(); ren.campaignId = target1.Id; ren.getProds(); Map tempMap = new Map(); tempMap.put('GI-290镜子', '1'); tempMap.put('EU-ME2', '2'); tempMap.put('OTV-S300', '4'); ren.planProductMap = tempMap; ren.save(); Test.stopTest(); } static testMethod void unitTest05() { OPDPlan__c target1 = new OPDPlan__c(); target1.OPDType__c = '事件'; target1.NoOpp_Reason__c = 'HCP对应'; insert target1; Date t1 = Date.today(); Event e = new Event( StartDateTime = Datetime.newInstance(t1.year(), t1.month(), t1.day(), 9, 0, 0), EndDateTime = Datetime.newInstance(t1.year(), t1.month(), t1.day(), 10, 0, 0), Opd_Plan__c = target1.Id, noOpp_Reason__c = 'HCP对应' ); insert e; Plan_Rental_Equipment__c plan1 = new Plan_Rental_Equipment__c(OPD_Plan__c = target1.Id,Rental_Equipment__c = 'OTV-S300',Rental_Quantity__c = '3'); insert plan1; List res = new List(); Rental_Equipment__c re1 = new Rental_Equipment__c(Name = 'GI-290镜子'); res.add(re1); Rental_Equipment__c re2 = new Rental_Equipment__c(Name = 'EU-ME2'); res.add(re2); Rental_Equipment__c re3 = new Rental_Equipment__c(Name = 'OTV-S190'); res.add(re3); Rental_Equipment__c re4 = new Rental_Equipment__c(Name = 'CV-170'); res.add(re4); Rental_Equipment__c re5 = new Rental_Equipment__c(Name = 'OTV-S300'); res.add(re5); insert res; Test.startTest(); RentalEquipmentCreateController ren = new RentalEquipmentCreateController(); ren.opdId = target1.Id; ren.getProds(); Map tempMap = new Map(); tempMap.put('GI-290镜子', '1'); tempMap.put('EU-ME2', '2'); tempMap.put('OTV-S300', '4'); ren.planProductMap = tempMap; ren.save(); Test.stopTest(); } }