高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
@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();
    }
}