• Mahesh Nagarwal
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
@isTest
private class AccountWrapper_Tests {
  @testSetup
  static void loadTestData(){
    List<Account> accounts = (List<Account>) Test.loadData(Account.SObjectType, 'accountData');
    List<Opportunity> opps = new List<Opportunity>();
    for(Account a : accounts){
      opps.addAll(TestFactory.generateOppsForAccount(a.id, 1000.00, 5));
// anyone tell me where to see for that variable wether it is there are not?
    } 
    insert opps;
  }

  @isTest static void testPositiveRoundedAveragePrice() {
    List<AccountWrapper> accounts = new List<AccountWrapper>();
    for(Account a : [SELECT ID, Name FROM ACCOUNT]){
      accounts.add(new AccountWrapper(a));
    }
    // sanity check asserting that we have opportunities before executing our tested method.
    List<Opportunity> sanityCheckListOfOpps = [SELECT ID FROM Opportunity];
    System.assert(sanityCheckListOfOpps.size() > 0, 'You need an opportunity to continue');
    Test.startTest();
    for(AccountWrapper a : accounts){
      System.assertEquals(a.getRoundedAvgPriceOfOpps(), 1000.00, 'Expected to get 1000.00');
    }
    Test.stopTest();
  }
    

      @isTest static void testHighPriority() {
        List<AccountWrapper> accounts = new List<AccountWrapper>();
        for(Account a : [SELECT ID, Name FROM ACCOUNT]){
            accounts.add(new AccountWrapper(a));}

          
            List<Opportunity> opps = new List<Opportunity>();
            opps = [SELECT Id,Amount FROM Opportunity];
              for(Opportunity opp :opps ) {
                  opp.amount =2000000;
              }
          update opps;
    
    Test.startTest();
      for(AccountWrapper a : accounts){
      System.assertEquals(a.isHighPriority(), true, 'Priority expected to be high');
      System.debug('get rounded price of opps for accounts b:'+ a.getRoundedAvgPriceOfOpps());
    }
    Test.stopTest();
  }
}