liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
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
@isTest
private class ConsumSelectControllerTest {
 
    static testMethod void testUnAssign() {
        Oly_TriggerHandler.bypass('ConsumApplyTriggerHandler');
        //Oly_TriggerHandler.bypass('ConsumApplyEquipmentSetDetailHandler');
        Oly_TriggerHandler.bypass('ConsumApplyEquipmentSetHandler');
        FixtureUtil.SkipTrigger = true;
        //StaticParameter.EscapeVMCTrigger = true;
        ConsumTestDataFactory factory = new ConsumTestDataFactory();
        factory.setupTestData();
        factory.selectDetails();
        try {
            factory.approve();
        } catch (Exception e) {
            
        }
        
        factory.unAssign();
        Consum_Apply_Equipment_Set_Detail__c caesd = [SELECT Id, RAESD_Status__c, Consum_Apply_Equipment_Set__c FROM Consum_Apply_Equipment_Set_Detail__c];
        // System.assertEquals('待分配', caesd.RAESD_Status__c);
 
        PageReference ref = new PageReference('/apex/ConsumSelect?recid=' + caesd.Consum_Apply_Equipment_Set__c);
        Test.setCurrentPage(ref);
        ConsumSelectController controller = new ConsumSelectController();
        CreateRelationListPagingCmpCtrl cmp = new CreateRelationListPagingCmpCtrl();
        cmp.pageController = controller;
        controller.myComponentController.init();
        controller.init();
        
        controller.searchOpp();
        //System.assertEquals(1, controller.viewList.size());
 
        Test.startTest();
        controller.tradeCheckTwo();
        caesd.Fen_Pei_Shu_Liang_Jia__c = 1;
        controller.save();
        Test.stopTest();
 
        caesd = [SELECT RAESD_Status__c FROM Consum_Apply_Equipment_Set_Detail__c];
        // System.assertEquals('已分配',caesd.RAESD_Status__c);
    }
 
    static testMethod void testSave() {
        Oly_TriggerHandler.bypass('ConsumApplyTriggerHandler');
        FixtureUtil.SkipTrigger = true;
        ConsumTestDataFactory factory = new ConsumTestDataFactory();
        factory.setupTestData();
        //factory.selectDetails();
        // try {
        //     factory.approve(); 
        // } catch (Exception e) {
            
        // }
 
        factory.defaultAssign();
        Consum_Apply_Equipment_Set_Detail__c caesd = [SELECT Id, RAESD_Status__c, Consum_Apply_Equipment_Set__c FROM Consum_Apply_Equipment_Set_Detail__c];
        // System.assertEquals('已分配', caesd.RAESD_Status__c);
 
        PageReference ref = new PageReference('/apex/ConsumSelect?recid=' + caesd.Consum_Apply_Equipment_Set__c);
        Test.setCurrentPage(ref);
        ConsumSelectController controller = new ConsumSelectController();
        CreateRelationListPagingCmpCtrl cmp = new CreateRelationListPagingCmpCtrl();
        cmp.pageController = controller;
        controller.myComponentController.init();
        controller.init();
        controller.searchOpp();
        List<Consum_Apply_Equipment_Set_Detail__c> caesdList = [SELECT Id FROM Consum_Apply_Equipment_Set_Detail__c];
        controller.setViewList(caesdList);
        System.assertEquals(1, controller.viewList.size());
 
        Test.startTest();
        controller.viewList[0].check = true;
        caesd = (Consum_Apply_Equipment_Set_Detail__c) controller.viewList[0].sobj;
        caesd.Fen_Pei_Shu_Liang_Jia__c = 0;
        controller.save();
        Test.stopTest();
        // 一览下全都已分配的话,就不能取消分配
        // caesd = [SELECT RAESD_Status__c FROM Consum_Apply_Equipment_Set_Detail__c];
        // System.assertEquals('已分配',caesd.RAESD_Status__c);
    }
 
    static testMethod void testCoverUp() {
        ConsumSelectController.test();
    }
}