Here is my complete class and i want to create its test class
public with sharing class MultiCurrencyHandler {
public static Boolean isMultiCurrencyOrg(){
try{
list<SObject> currencyTypes = Database.query('SELECT IsoCode, ConversionRate FROM CurrencyType limit 1');
}catch(Exception e){
// Multi Currency is not supported.
if(e.getMessage().contains('sObject type \'CurrencyType\' is not supported.'))
return false;
}
return true;
}
public static map<String, Double> getCurrencyTypeByISOCode(){
map<String, Double> mapCurrencyTypeByISOCode = new map<String, Double>();
for(sObject currType : Database.query( 'SELECT IsoCode, ConversionRate FROM CurrencyType') ){
mapCurrencyTypeByISOCode.put( String.valueOf( currType.get('IsoCode') ), Double.valueOf(currType.get('ConversionRate') ) );
}
return mapCurrencyTypeByISOCode;
}
public static Double convertCurrencyWith( Double oCurrencyConversionRate, Double nCurrencyConversionRate, Double amount, String nCurrencyType){
//Convert incoming Opportuntiy Amount into USD...
amount = amount / oCurrencyConversionRate;
//convert amount as per new currency.
if( nCurrencyType != 'USD' ){
amount = amount * nCurrencyConversionRate;
}
return amount;
}
}
getCurrencyTypeByISOCode()
should cache its results in a static variable so every time it is called in a transaction, it doesn't have to requery the currency rates and burn up valuable soql; same forisMultiCurrencyorg()