@isTest
private class MonthlyVisitBatch1Tset {

    @IsTest
	static void TestMethod01() {

		Opportunity opp = new Opportunity();
        opp.Name = 'aiueo';
        opp.StageName = 'contact';
        opp.CloseDate = Date.today();
        insert opp;

		List<String> str = new List<String>();
		str.add(opp.Id);

		Datetime dt = DateTime.now().addDays(-4);
		Date dtDate = System.today().addDays(-4);

		Daily_Report__c dr = new Daily_Report__c();
		dr.reported_date__c = dtDate;
		dr.Status__c = '申請中';
	    dr.Reporter__c = Userinfo.getUserId();
		insert dr;

		RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
		RecordType rtDoc = [select id from RecordType where IsActive = true and DeveloperName =:'Doctor'];

		Account acc = new Account();
        acc.RecordTypeId = rectCo.Id;
        acc.Name = '病院テスト1';
        insert acc;

		Contact con = new Contact();
        con.Doctor_Division1__c = '院长';
        con.LastName = 'yuanzhang';
        con.RecordTypeId = rtDoc.id;
        con.AccountId = acc.Id;
        Contact con2 = new Contact();
        con2.Doctor_Division1__c = '副主任';
        con2.LastName = 'zhuren';
        con2.RecordTypeId = rtDoc.id;
        con2.AccountId = acc.Id;
        insert new Contact[] {con, con2};

		Event__c ec = new Event__c();
		ec.Daily_Report__c = dr.Id;
		ec.StartDateTime__c = System.now();
		ec.EndDateTime__c = System.now();
		ec.Subject__c = 'Subject';
		ec.Location__c = 'Location';
		ec.ActivityDate__c = dr.reported_date__c;
		ec.Visitor1_ID__c = con.Id;
		ec.Visitor2_ID__c = con2.Id;
		insert ec;

		Event_Oppotunity__c eo = new Event_Oppotunity__c();
        eo.Opportunity__c = opp.Id;
        eo.End_Time__c = dt;
        eo.Daily_Report__c = dr.Id;
        eo.EventC_ID__c = ec.Id;
		insert eo;

		Test.StartTest();
		Database.executeBatch( new MonthlyVisitBatch1(),100);
		Database.executeBatch( new MonthlyVisitBatch1(str),100);
		Test.stopTest();
	}

}