Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. static testmethod void TestMethod() {
  2.  
  3.  
  4. //Created A dummy Account and Opportunity records I.e Acc & Opt
  5.  
  6. //getting standard pricebook id
  7. Id pricebookId = Test.getStandardPricebookId();
  8.  
  9. //Created a product
  10. Product2 prod = new Product2(
  11. Name = 'Product X',
  12. ProductCode = 'Pro-X',
  13. isActive = true,
  14. IsAvailable__c = True // setting field value as true
  15. );
  16. insert prod;
  17.  
  18.  
  19. //Created pricebook entry
  20. PricebookEntry pbEntry = new PricebookEntry(
  21. Pricebook2Id = pricebookId,
  22. Product2Id = prod.Id,
  23. UnitPrice = 100.00,
  24. IsActive = true
  25. );
  26. insert pbEntry;
  27.  
  28. //created opportunity line item.
  29. OpportunityLineItem oli = new OpportunityLineItem(
  30. OpportunityId = opt.Id,
  31. units__c = 25,
  32. Type__c = 'No. Users',
  33. PricebookEntryId = pbEntry.Id,
  34. TotalPrice = 200,
  35. Quantity = 1
  36. );
  37.  
  38. insert oli;
  39.  
  40. system.debug('oli.IsAvailable__c ='+ oli.IsAvailable__c ); // This is returing me value as false
  41.  
  42. Test.startTest();
  43.  
  44. //calling my required methods here
  45.  
  46. Test.stopTest();
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement