@isTest private class AgencyHospitalHandlerTest { public static Account account1 = new Account(); public static Account account2 = new Account(); public static Agency_Hospital_Link__c aHosLink = new Agency_Hospital_Link__c(); static testMethod void test_beforeExecute() { // 取引先 account1.Name = 'test1医院'; account1.RecordTypeId = '01210000000QemG'; insert account1; account2.Name = 'test1经销商'; account2.RecordTypeId = '01210000000Qem1'; insert account2; List accTestList = [SELECT Id, Name FROM Account order by Name]; System.debug('GYFaccTestList='+accTestList); System.assertEquals(10, accTestList.size()); System.assertEquals('test1医院', accTestList[0].Name); //经销商医院データを作る aHosLink.Name = 'test1经销商医院'; aHosLink.Hospital__c = account1.Id; aHosLink.Agency__c = account2.Id; Test.startTest(); insert aHosLink; //经销商医院名前を変更する aHosLink.Name = 'test经销商医院1'; update aHosLink; Test.stopTest(); List aHosLinkTestList = [SELECT Id, Name FROM Agency_Hospital_Link__c]; System.assertEquals(1, aHosLinkTestList.size()); System.assertEquals( 'test1医院',aHosLinkTestList[0].Name); } @isTest static void test_shareAgency_Hospital_Link_ToRole() { StaticParameter.EscapeNFM001AgencyContractTrigger = true; MergeAgencyActivityBatchTest.makeNormalData(true); // assert List tList = [SELECT Name, Hospital__c, Agency__c FROM Agency_Hospital_Link__c ORDER BY Id LIMIT 2]; System.assertEquals(2, tList.size()); System.assertEquals(MergeAgencyActivityBatchTest.agency1.Id, tList[0].Agency__c); System.assertEquals(MergeAgencyActivityBatchTest.agency2.Id, tList[1].Agency__c); List tsList = [SELECT Id FROM Agency_Hospital_Link__share WHERE ParentId = :tList AND RowCause = 'Manual']; // System.assertEquals(2, tsList.size()); // Test.startTest(); // Delete tList[0]; // Test.stopTest(); // tsList = [SELECT Id // FROM Agency_Hospital_Link__share WHERE ParentId = :tList AND RowCause = 'Manual']; // System.assertEquals(1, tsList.size()); // UnDelete tList[0]; // tsList = [SELECT Id // FROM Agency_Hospital_Link__share WHERE ParentId = :tList AND RowCause = 'Manual']; // System.assertEquals(2, tsList.size()); } }