@isTest
private class ConsumTrialControllerTest {
    // 造出待分配的数据
    @testSetup static void setupTestData(){
        ConsumTestDataFactory factory = new ConsumTestDataFactory();
        factory.setupTestData();
        factory.selectDetails();
    }
    static testMethod void testSave() {
        Consum_Apply__c ca = [SELECT Id FROM Consum_Apply__c LIMIT 1];
        Consum_Apply_Equipment_Set_Detail__c caesd = [SELECT Id
                                                           , Consum_Start_Date__c
                                                           , Trial_User__c
                                                           , Follower_User__c
                                                        FROM Consum_Apply_Equipment_Set_Detail__c
                                                        LIMIT 1];
        System.assertEquals(null, caesd.Trial_User__c);
        System.assertEquals(null, caesd.Follower_User__c);

        PageReference ref = new PageReference('/apex/ConsumTrial');
        ref.getParameters().put('Id',ca.Id);
        ref.getParameters().put('canedit','true');
        Test.setCurrentPage(ref);
        ConsumTrialController controller = new ConsumTrialController(null);
        controller.init();
        System.assertEquals(1, controller.pageB.rowBList.size());

        Date today = System.Today();
        Id userId = UserInfo.getUserId();

        Test.startTest();
        controller.getShowDemonstrationOps();
        controller.getOperationTypeOps();
        controller.getCase_OR_animal_organOpsHead();
        controller.getCase_OR_animal_organOps();
        controller.changeFixModel();
        controller.pageB.rowBList[0].checked = true;
        caesd = (Consum_Apply_Equipment_Set_Detail__c) controller.pageB.rowBList[0].rnd;
        caesd.Trial_User__c = '我';
        caesd.Follower_User__c = userId;
        controller.saveRecord();
        Test.stopTest();

        caesd = [SELECT Id
                      , Consum_Start_Date__c
                      , Trial_User__c
                      , Follower_User__c
                  FROM Consum_Apply_Equipment_Set_Detail__c
                  LIMIT 1];
        System.assertEquals('我', caesd.Trial_User__c);
        System.assertEquals(userId, caesd.Follower_User__c);
    }

    static testMethod void testCoverUp() {
        ConsumTrialController.test();
    }
}