高章伟
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
@isTest
public class PCLLostReportByTcmControllerTest {
    @testSetup
    private static void testSetup(){
        PCLLostProduct2AssetHandlerTest.setUp();
    }
    @isTest
    private static void TestInit_Create(){
        // create Test
        Opportunity opp1 = [select id from Opportunity limit 1];
        PageReference page = 
        new PageReference('/apex/PCLLostReportPageByTcm?oppId=' 
            +opp1.Id+ '&pageStatus=Create' + + '&lostType=失单');
        page.setRedirect(true);
        System.Test.setCurrentPage(page);
        Lost_cancel_report__c lcr1 = new Lost_cancel_report__c();
        PCLLostReportByTcmController conTest = 
        new PCLLostReportByTcmController(new ApexPages.StandardController(lcr1));
        conTest.init();
    }
    @isTest
    private static void TestInit_Edit(){
        EditLoad();
    }
    @isTest
    private static void TestInit_Other(){
        Lost_cancel_report__c lcr = 
        [select id 
        from Lost_cancel_report__c 
        where  LostType__c = '部分失单' limit 1];
        PageReference page2 = 
        new PageReference('/apex/PCLLostReportPageByTcm?Id=' 
            +lcr.Id+ '&pageStatus=Edit');
        page2.setRedirect(true);
        System.Test.setCurrentPage(page2);
        PCLLostReportByTcmController conTest2 = 
        new PCLLostReportByTcmController(new ApexPages.StandardController(lcr));
        conTest2.init();
        page2 = 
        new PageReference('/apex/PCLLostReportPageByTcm?pageStatus=Create');
        page2.setRedirect(true);
        System.Test.setCurrentPage(page2);
        conTest2 = 
        new PCLLostReportByTcmController(new ApexPages.StandardController(lcr));
        conTest2.init();
        page2 = 
        new PageReference('/apex/PCLLostReportPageByTcm?oppId=' 
            +lcr.Id+ '&pageStatus=Create');
        page2.setRedirect(true);
        System.Test.setCurrentPage(page2);
        conTest2 = 
        new PCLLostReportByTcmController(new ApexPages.StandardController(lcr));
        conTest2.init();
 
        page2 = 
        new PageReference('/apex/PCLLostReportPageByTcm?pageStatus=Edit');
        page2.setRedirect(true);
        System.Test.setCurrentPage(page2);
        conTest2 = 
        new PCLLostReportByTcmController(new ApexPages.StandardController(lcr));
        conTest2.init();
        page2 = 
        new PageReference('/apex/PCLLostReportPageByTcm');
        page2.setRedirect(true);
        System.Test.setCurrentPage(page2);
        conTest2 = new PCLLostReportByTcmController(new ApexPages.StandardController(lcr));
        conTest2.init();
        PCLLostReportByTcmController.LostReport a =new PCLLostReportByTcmController.LostReport();
        PCLLostReportByTcmController.LostBrand ab =new PCLLostReportByTcmController.LostBrand(0, new list<PCLLostProduct__c>());
    }
    public static PCLLostReportByTcmController EditLoad(){
        // View Edit Test
        Lost_cancel_report__c lcr2 = 
        [select id 
        from Lost_cancel_report__c 
        where  LostType__c = '失单' limit 1];
        PageReference page2 = 
        new PageReference('/apex/PCLLostReportPageByTcm?Id=' 
            +lcr2.Id + '&pageStatus=Edit');
        page2.setRedirect(true);
        System.Test.setCurrentPage(page2);
        PCLLostReportByTcmController conTest2 = 
        new PCLLostReportByTcmController(new ApexPages.StandardController(lcr2));
        conTest2.init();
       
        return conTest2;
        
    }
    @isTest
    private static void TestaddBrandAndProduct(){
        PCLLostReportByTcmController conTest2 = EditLoad();
        conTest2.addBrand();
        conTest2.addProduct();
        conTest2.RemoveBrandNo = 1;
        conTest2.Remove();
    }
    @isTest
    private static void TestCancel(){
        PCLLostReportByTcmController conTest2 = EditLoad();
        conTest2.cancel();
    }
    @isTest
    private static void TestSave(){
        PCLLostReportByTcmController conTest2 = EditLoad();
        conTest2.save();
    }
 
 
    @isTest
    private static void DataCheck(){
        PCLLostReportByTcmController conTest2 = EditLoad();
        conTest2.LostReport.LostReport.LostType__c = null;
        conTest2.LostReport.LostBrands[0].lostBrand.LostPrice__c = null;
        conTest2.LostReport.LostBrands[0].lostBrand.Lost_reason_main__c = null;
        conTest2.LostReport.LostBrands[0].LostProducts[0].Quantity__c =null;
        conTest2.LostReport.LostBrands[0].lostBrand.Agency__c = null;
        conTest2.DataCheck();
        conTest2.LostReport.LostBrands[0].lostBrand.Lost_By_Company__c = null;
        conTest2.DataCheck();
        conTest2.LostReport.LostBrands[0].LostProducts  = new list<PCLLostProduct__c>{
            new PCLLostProduct__c(Quantity__c = 0) };
         conTest2.DataCheck();
    }
    @isTest
    private static void TestEdit2(){
        PCLLostReportByTcmController conTest2 = EditLoad();
        conTest2.edit2();
    }
 
    @isTest
    private static void TestSubmit(){
        PCLLostReportByTcmController conTest2 = EditLoad();
        conTest2.submit();
    }
 
 
 
 
}