I have been building test classes and coping parts from existing classes and reusing them in my new class. I want to create two pricebook entries one in the standard pricebook and one in a custom pricebook. I figure I can insert both at the same time by creating the record in list and then inserting the list. However, I get this error when I try to compile the class in Sublime.
Invalid field initializer: pbeStandard.Pricebook2Id (Line: 43, Column: 4)
What am I doing wrong to add the pricebookEntry for the test class?
example test class:
List<PricebookEntry> pbeL = new List<PricebookEntry>();
// Create A Pricebook
Pricebook2 pb = new Pricebook2();
pb.Name = 'NPD Price Book';
pb.IsActive = true;
pb.CurrencISOCode = 'USD';
pb.Description = 'Custom Pricebook';
insert pb;
// Create Product
Product2 prod = new Product2();
prod.Name = 'Test Product';
prod.ProductCode = 'Prod Code';
prod.IsActive = true;
prod.Product_Type__c = 'Subscription';
prod.Product_Launch_Date__c = System.today();
prod.ProductCode = 'NPD9999999';
prod.Family = 'NPD Solutions';
prod.CurrencyISOCode = 'USD';
prod.Product_Identifier__c = 'Test Product';
insert prod;
// Get Standard Pricebook
Id pbstd = Test.getStandardPricebookId();
// Create Pricebook Entries
PricebookEntry pbeStanadrd = new PricebookEntry(
pbeStandard.Pricebook2Id = pbstd,
pbeStandard.Product2Id = prod.Id,
pbeStandard.UnitPrice = 100.00,
pbeStandard.IsActive = true,
pbeStandard.CurrencyISOCode = 'USD');
pbeL.add(pbeStandard);
PricebookEntry pbeC = new PricebookEntry(
pbeC.Pricebook2Id = pb.Id,
pbeC.Product2Id = prod.Id,
pbeC.UnitPrice = 100.00,
pbeC.IsActive = true,
pbeC.CurrencyISOCode = 'USD');
pbeL.add(pbeC);
insert pbeL;