@isTest
|
private class EnquiryDetailsControllerTest {
|
|
static testMethod void EnquiryDetailsControllerTest() {
|
Opportunity CreateOppo = new Opportunity();
|
CreateOppo.Name='TestName';
|
CreateOppo.Opportunity_stage__c='预算没有批准';
|
CreateOppo.Application_Amount_Submit__c=2333;
|
CreateOppo.Budget_Amount_Approval__c=6666;
|
CreateOppo.Bid_Date__c=Date.today().addDays(-12);
|
CreateOppo.Close_Forecasted_Date__c=Date.today().addDays(10);
|
CreateOppo.CloseDate=Date.today().addDays(12);
|
CreateOppo.Closing_Bid_Date__c=Date.today().addDays(-8);
|
CreateOppo.StageName = '出荷';
|
insert CreateOppo;
|
EnquiryDetailsController EDC = new EnquiryDetailsController();
|
EDC.ESetId = CreateOppo.id;
|
EDC.init();
|
EDC.insOppo.Close_Forecasted_Date__c = null;
|
EDC.save();
|
//system.assertEquals('预测COM签约日不能为空',ApexPages.getMessages()[0].getDetail());
|
EDC = new EnquiryDetailsController();
|
EDC.ESetId = CreateOppo.id;
|
EDC.init();
|
EDC.insOppo.CloseDate=null;
|
EDC.save();
|
//system.assertEquals('预测发货日不能为空',ApexPages.getMessages()[1].getDetail());
|
EDC = new EnquiryDetailsController();
|
EDC.ESetId = CreateOppo.id;
|
EDC.init();
|
EDC.insOppo.Close_Forecasted_Date__c = Date.today().addDays(-2);
|
EDC.save();
|
//system.assertEquals('预测COM签约日不允许登录过去日期',ApexPages.getMessages()[2].getDetail());
|
EDC = new EnquiryDetailsController();
|
EDC.ESetId = CreateOppo.id;
|
EDC.init();
|
EDC.insOppo.Close_Forecasted_Date__c = Date.today().addDays(14);
|
EDC.insOppo.CloseDate =Date.today().addDays(12);
|
EDC.save();
|
//system.assertEquals('预测COM签约日不允许晚于预测发货日',ApexPages.getMessages()[3].getDetail());
|
EDC = new EnquiryDetailsController();
|
EDC.ESetId = CreateOppo.id;
|
EDC.init();
|
EDC.insOppo.Bid_Date__c = Date.today().addDays(14);
|
EDC.insOppo.Closing_Bid_Date__c =Date.today().addDays(8);
|
EDC.save();
|
//system.assertEquals('中标日不允许早于招标日',ApexPages.getMessages()[1].getDetail());
|
|
EDC = new EnquiryDetailsController();
|
EDC.ESetId = CreateOppo.id;
|
EDC.init();
|
EDC.insOppo.Bid_Date__c = Date.today().addDays(14);
|
EDC.insOppo.Closing_Bid_Date__c =Date.today().addDays(12);
|
EDC.save();
|
//system.assertEquals('预测OCM签约日不允许早于中标日',ApexPages.getMessages()[5].getDetail());
|
EDC = new EnquiryDetailsController();
|
EDC.ESetId = CreateOppo.id;
|
EDC.init();
|
EDC.insOppo.Opportunity_stage__c = '确定了对手参数';
|
EDC.insOppo.Application_Amount_Submit__c =null;
|
EDC.save();
|
//system.assertEquals('提交申请金额不能为空',ApexPages.getMessages()[2].getDetail());
|
EDC = new EnquiryDetailsController();
|
EDC.ESetId = CreateOppo.id;
|
EDC.init();
|
EDC.insOppo.Opportunity_stage__c = '确定了对手参数';
|
EDC.insOppo.Budget_Amount_Approval__c =null;
|
EDC.save();
|
//system.assertEquals('预算批准金额不能为空',ApexPages.getMessages()[3].getDetail());
|
/*EDC = new EnquiryDetailsController();
|
EDC.ESetId = CreateOppo.id;
|
EDC.init();
|
EDC.insOppo.Bid_Date__c= Date.today().addDays(-4);
|
EDC.insOppo.Closing_Bid_Date__c = Date.today().addDays(-4);
|
EDC.insOppo.Close_Forecasted_Date__c =Date.today().addDays(-2);
|
EDC.insOppo.CloseDate =Date.today().addDays(-1);
|
EDC.save();
|
system.assertEquals('预测发货日不允许登录过去日期',ApexPages.getMessages()[7].getDetail());*/
|
EDC = new EnquiryDetailsController();
|
EDC.ESetId = CreateOppo.id;
|
EDC.init();
|
EDC.save();
|
}
|
}
|