Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trigger CustomObject on CustomObject__c (after update) {
- EventBus.publish(new Platform_Event__e());
- }
- @isTest private CustomObjectTriggerTest() {
- static testMethod void testTrigger() {
- CustomObject__c rec = new CustomObject__c(Name = 'A');
- Test.startTest();
- rec.Name = 'b';
- update rec;
- Test.stopTest();
- //System.assert( ... ??? Is there anything here we can assert? )
- }
- }
- trigger CustomObject on CustomObject__c (after update) {
- CustomObjectService.publishEvent();
- }
- public class CustomObjectService() {
- @testVisible private static List<Platform_Event__e> eventList = new List<Platform_Event__e>();
- public static void publishEvent() {
- Platform_Event__e eve = new Platform_Event__e();
- eventList.add(eve);
- EventBus.publish(eve);
- }
- }
- @isTest private CustomObjectTriggerTest() {
- static testMethod void testTrigger() {
- CustomObject__c rec = new CustomObject__c(Name = 'A');
- Test.startTest();
- rec.Name = 'b';
- update rec;
- Test.stopTest();
- System.assert( 1, CustomObjectService.eventList.size(), 'There should be one element in the list' );
- }
- }
Add Comment
Please, Sign In to add comment