0

@isTest public class HandlerClassTest { @isTest public static void InsertTestMethod() {

    List<Account> accList = new  List<Account> ();
    
    for(Integer i=0;i<5;i++)
    {
        Account acc=new Account();
        acc.Name='Test'+i;
        acc.MinAmount__c =100;
        acc.MaxAmount__c = 600;
         
        accList.add(acc);
    }
    
    insert accList;
    
    List<Opportunity> oppList = new List<Opportunity>();
    
    For(Account acc:accList)
    {
        Opportunity opp= new Opportunity ();
        opp.Name=acc.Name;
        opp.CloseDate=system.today();
        opp.StageName='Value Proposition';
        opp.Amount=900;
        
        oppList.add(opp);
    }
    
    insert oppList;
    
    List<Account> AccCheck = [select Id,MaxAmount__c from Account where id =: accList[0].id];
    
              system.debug('Max is' +AccCheck[0].MaxAmount__c )   ;      
    
            system.assertEquals( 900; AccCheck[0].MaxAmount__c );
       
    
}

}

Error getting -- in system.assertEquals as -- 1.Method does not exist or incorrect signature: void assertEquals(Integer) from the type System 2.Expression cannot be a statement.

Can we compare a currency field and number field in system.assertEquals ...If yes ...How ???

Edited -- changed the MaxAmount field to currency still this error shows

2 Answers 2

2

You have a semi-colon instead of a comma here between the arguments:

system.assertEquals( 900; AccCheck[0].MaxAmount__c );

that is causing the compilation problems.

Instead (using new Assert class and best practice assert message):

Assert.areEqual( 900, AccCheck[0].MaxAmount__c, 'some message' );
-1

If you want to get a decimal value, just get it into a variable something like this:

Decimal currencyFieldValue = myObject.CurrencyField__c;

if you want just the number then use

integer.valueOf(acc1.AnnualRevenue)

1
  • 2
    Please don't explicitly ask for best answer and upvote as part of the answer - this adds nothing to your answer. It would also be best if you read the edit help to understand how to format your answer.
    – Phil W
    Nov 7, 2023 at 7:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .