Guest User

Untitled

a guest
Jan 16th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. trigger CustomObject on CustomObject__c (after update) {
  2. EventBus.publish(new Platform_Event__e());
  3. }
  4.  
  5. @isTest private CustomObjectTriggerTest() {
  6. static testMethod void testTrigger() {
  7. CustomObject__c rec = new CustomObject__c(Name = 'A');
  8. Test.startTest();
  9. rec.Name = 'b';
  10. update rec;
  11. Test.stopTest();
  12. //System.assert( ... ??? Is there anything here we can assert? )
  13. }
  14. }
  15.  
  16. trigger CustomObject on CustomObject__c (after update) {
  17. CustomObjectService.publishEvent();
  18. }
  19.  
  20. public class CustomObjectService() {
  21. @testVisible private static List<Platform_Event__e> eventList = new List<Platform_Event__e>();
  22. public static void publishEvent() {
  23. Platform_Event__e eve = new Platform_Event__e();
  24. eventList.add(eve);
  25. EventBus.publish(eve);
  26. }
  27. }
  28.  
  29. @isTest private CustomObjectTriggerTest() {
  30. static testMethod void testTrigger() {
  31. CustomObject__c rec = new CustomObject__c(Name = 'A');
  32. Test.startTest();
  33. rec.Name = 'b';
  34. update rec;
  35. Test.stopTest();
  36. System.assert( 1, CustomObjectService.eventList.size(), 'There should be one element in the list' );
  37. }
  38. }
Add Comment
Please, Sign In to add comment