高章伟
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
@isTest
private class BeforeSSOpportunityBatchTest {
    
    @isTest 
    static void updateTest() {
        // Implement test code
        Opportunity opp1 = new Opportunity(Name='aiueo1', StageName='引合', CurrencyIsoCode='USD', CloseDate=Date.today(),Close_Forecasted_Date__c=Date.today());
        Opportunity opp2 = new Opportunity(Name='aiueo2', StageName='引合', CurrencyIsoCode='CNY', CloseDate=Date.today(),Close_Forecasted_Date__c=Date.today());
        insert new Opportunity[] {opp1, opp2};
        List<Opportunity> opp = [select id,StageName from Opportunity];
        System.assertEquals(opp[0].StageName, '引合');
        System.assertEquals(opp[1].StageName, '引合');
        System.Test.StartTest();
        Id execBTId = Database.executeBatch(new BeforeSSOpportunityBatch(), 5);
        System.Test.StopTest();
        
        opp1 = [select id,Monthly_ship_target_txt__c,Monthly_ship_target__c,Monthly_order_target_txt__c,Monthly_order_target__c from Opportunity where Id=:opp1.Id];
        opp2 = [select id,Monthly_ship_target_txt__c,Monthly_ship_target__c,Monthly_order_target_txt__c,Monthly_order_target__c from Opportunity where Id=:opp2.Id];
        System.assertEquals(opp1.Monthly_ship_target_txt__c, opp1.Monthly_ship_target__c ? '1':'0');
        System.assertEquals(opp1.Monthly_order_target_txt__c, opp1.Monthly_order_target__c ? '1':'0');
        System.assertEquals(opp2.Monthly_ship_target_txt__c, opp2.Monthly_ship_target__c ? '1':'0');
        System.assertEquals(opp2.Monthly_order_target_txt__c, opp2.Monthly_order_target__c ? '1':'0');
    }
    
}