function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
John AthitakisJohn Athitakis 

Test Class Question: Method does not exist or incorrect signature: system.assertEquals(Decimal)

Getting a strange error on some test cases when comparing two decimal values together. Error occurs on line 27 and would probably occur again on line 32. 

 
@isTest 
/*
Author: --
Test for Trigger: PR2PO_ExchangeRateTest
*/
public class PR2PO_ExchangeRateTest {
	static testMethod void validateExchangeTrigger() {
//Logic: 
        Vendor__c vendor=new Vendor__c();
        vendor.Name='Test';
        vendor.Billing_Contact_Email__c='test@puppetlabs.com';
        insert vendor; 
        Vendor__c vendorInserted = [SELECT Id FROM Vendor__c WHERE Billing_Contact_Email__c = 'test@puppetlabs.com' ];
        Purchase_Order__c order = new Purchase_Order__c();
        order.Vendor__c = vendorInserted.Id;
        order.Name = 'PO-99999-Test';
        order.Terms__c  = 'Net 30';
        order.Currency__c= 'GBP';
        order.Currency_Base__c='GBP';
        string newCurrencyCode=order.Currency_Base__c;
        order.Total__c=100.50;
        test.startTest();
        date startOfMonth = date.today().toStartofMonth().addMonths(-1);
        insert order;    
		system.assertEquals(startOfMonth , date.today().toStartofMonth().addMonths(-1));
        Exchange_Rate__c exchangeRate = [SELECT ConversionRate__c FROM Exchange_Rate__c WHERE StartDate__c <= today AND StartDate__c >= :startOfMonth AND IsoCode__c = :newCurrencyCode ORDER BY StartDate__c DESC LIMIT 1];
        system.assertEquals(order.ExchRate_to_USD__c = exchangeRate.ConversionRate__c);        
        order.Currency__c= 'EUR';
        order.Currency_Base__c='EUR';      
        update order;
        system.assertEquals(startOfMonth , date.today().toStartofMonth().addMonths(-1));
        Exchange_Rate__c exchangeRate2 = [SELECT ConversionRate__c FROM Exchange_Rate__c WHERE StartDate__c <= today AND StartDate__c >= :startOfMonth AND IsoCode__c = :newCurrencyCode ORDER BY StartDate__c DESC LIMIT 1];
        system.assertEquals(order.ExchRate_to_USD__c = exchangeRate2.ConversionRate__c);        
        order.Currency__c= 'USD';
        order.Currency_Base__c='USD'; 
        update order;
		system.assertEquals(order.ExchRate_to_USD__c = 1.0); 
        test.stopTest();  
    }
}

 
Best Answer chosen by John Athitakis
Hitendar Singh 9Hitendar Singh 9
Hi 

System.assertEquals accepts two or three Object parameters.

So in your case the invocation should look like below,
system.assertEquals(order.ExchRate_to_USD__c , exchangeRate.ConversionRate__c);   

Hope this helps

All Answers

Hitendar Singh 9Hitendar Singh 9
Hi 

System.assertEquals accepts two or three Object parameters.

So in your case the invocation should look like below,
system.assertEquals(order.ExchRate_to_USD__c , exchangeRate.ConversionRate__c);   

Hope this helps
This was selected as the best answer
John AthitakisJohn Athitakis
This is what happens without coffee!