@isTest
private class NFM116BatchTest {
    @TestSetup
    static void makeData(){
        Opportunity opp = new Opportunity();
        opp.Opportunity_No__c = 'XB-153P-06-S151289';
        opp.Opportunity_Category__c = 'ET';
        opp.StageName = '目標';
        opp.Authorized_DB_No__c = 'XB-153P-06-S151289';
        opp.Name = '::XB-153P-06-S151289';
        opp.Close_Forecasted_Date__c = Date.today();
        opp.CloseDate = Date.today();
        opp.Opp_Confirmation_Day__c = Date.today();
        insert opp;
        
        Statu_Achievements__c Statu1 = new Statu_Achievements__c();
        Statu1.ContractNO__c = 'SH-ET-191025';
        Statu1.Opportunity__c = opp.Id;
        Statu1.ContractAmount__c = 100;
        insert Statu1;

        eSignForm__c es = new eSignForm__c();
        es.Statu_Achievements__c = Statu1.Id;
        es.DNName__c = '11223344';
        es.agencyAutoSignUpStatus__c = '已批准';
        es.agencySignUpDate__c = Date.today().addDays(-1);
        es.salesManageConfirmDate__c  = Date.today().addDays(-1);
        es.HPSignUpStatus__c = '已批准';
        es.HPSignUpDate__c = Date.today().addDays(-1);
        es.HPConfirmDate__c = Date.today().addDays(-1);
        es.end_User__c = '契約';
        insert es;

        eSignFormLineItem__c esi = new eSignFormLineItem__c();
        esi.Count__c = 2;
        esi.agencyGoodStatus__c = '完好';
        esi.eSignForm__c = es.Id;
        insert esi;
        eSignFormLineItem__c esi2 = new eSignFormLineItem__c();
        esi2.Count__c = 2;
        esi2.agencyGoodStatus__c = '完好';
        esi2.eSignForm__c = es.Id;
        insert esi2;
    }
    static testMethod void testMethod1(){
        Test.startTest();
        Database.executeBatch(new NFM116Batch(), 200);
        Test.stopTest();
    }
    static testMethod void testMethod2(){
        Test.startTest();
        Database.executeBatch(new NFM116Batch(Date.today()), 200);
        Test.stopTest();
    }
    static testMethod void testMethod3(){
        Test.startTest();
        Database.executeBatch(new NFM116Batch(Date.today().addDays(-30), true), 200);
        Test.stopTest();
    }
    static testMethod void testMethod4(){
        Test.startTest();
        eSignForm__c es = [select Id from eSignForm__c];
        Database.executeBatch(new NFM116Batch(es.Id), 200);
        Test.stopTest();
    }
    static testMethod void testMethod5(){
        Test.startTest();
        eSignForm__c es = [select Id from eSignForm__c];
        Database.executeBatch(new NFM116Batch(new List<String>{es.id}), 200);
        Test.stopTest();
    }
}