@isTest
private class SetOlympusCalendarWorkDayBatchTest {
    static void setupTestData(){
        OlympusCalendar__c oc = new OlympusCalendar__c();
        oc.Date__c = System.Today();
        List<OlympusCalendar__c> ocList = new List<OlympusCalendar__c> ();
        ocList.add(oc);
        for(Integer i = 1;i<=60;i++){
            OlympusCalendar__c oc_i = new OlympusCalendar__c();
            OlympusCalendar__c oc_j = new OlympusCalendar__c();
            oc_i.Date__c = System.Today().addDays(i);
            oc_j.Date__c = System.Today().addDays(-i);
            ocList.add(oc_i);
            ocList.add(oc_j);
        }
        insert ocList;
    }
    static testMethod void testExecute() {
        setupTestData();
        Test.startTest();
        SetOlympusCalendarWorkDayBatch workDayBatch = new SetOlympusCalendarWorkDayBatch();
        Date today = System.Today();
        Datetime dt = Datetime.newInstance(today.year(), today.month(), today.day());
        String dt_str = dt.format('yyyy-MM-dd');
        List<OlympusCalendar__c> ocList = [
                SELECT Date__c
                FROM OlympusCalendar__c
                WHERE Date__c =: today
            ];
        workDayBatch.start(null);
        workDayBatch.execute(null, ocList);
        workDayBatch.finish(null);
        Test.stopTest();
        String soqlString = 'SELECT Date__c ';
        for(Integer i = 1;i<=30;i++){
            soqlString += ',After_' + i + '_WorkDay__c';
            soqlString += ',Before_' + i + '_WorkDay__c';
        }
        soqlString += ' FROM OlympusCalendar__c WHERE Date__c =' + dt_str;

        OlympusCalendar__c oc = Database.query(soqlString);
        for(Integer i = 1;i<=30;i++){
            //System.debug('qyj:' + 'After_' + i + '_WorkDay__c' + oc.get('After_' + i + '_WorkDay__c'));
            //System.debug('qyj:' + 'Before_' + i + '_WorkDay__c' + oc.get('Before_' + i + '_WorkDay__c'));
            System.assertNotEquals(null, oc.get('After_' + i + '_WorkDay__c'));
            System.assertNotEquals(null, oc.get('Before_' + i + '_WorkDay__c'));
        }
        System.assertEquals(0, workDayBatch.emailMessages.size());
    }
}