Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static testmethod void TestMethod() {
- //Created A dummy Account and Opportunity records I.e Acc & Opt
- //getting standard pricebook id
- Id pricebookId = Test.getStandardPricebookId();
- //Created a product
- Product2 prod = new Product2(
- Name = 'Product X',
- ProductCode = 'Pro-X',
- isActive = true,
- IsAvailable__c = True // setting field value as true
- );
- insert prod;
- //Created pricebook entry
- PricebookEntry pbEntry = new PricebookEntry(
- Pricebook2Id = pricebookId,
- Product2Id = prod.Id,
- UnitPrice = 100.00,
- IsActive = true
- );
- insert pbEntry;
- //created opportunity line item.
- OpportunityLineItem oli = new OpportunityLineItem(
- OpportunityId = opt.Id,
- units__c = 25,
- Type__c = 'No. Users',
- PricebookEntryId = pbEntry.Id,
- TotalPrice = 200,
- Quantity = 1
- );
- insert oli;
- system.debug('oli.IsAvailable__c ='+ oli.IsAvailable__c ); // This is returing me value as false
- Test.startTest();
- //calling my required methods here
- Test.stopTest();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement