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
Egor PalatovEgor Palatov 

how to write test class for this sort method?


public String sortExpression{
		get{
			return sortExp;
		}
		set{
			if (value == sortExp){
				sortDirection = (sortDirection == 'ASC')? 'DESC' : 'ASC';
			}
			else{
				sortDirection = 'ASC';
				sortExp = value;
			}
		}
	}

	public String getSortDirection(){ 
        if (sortExpression == null || sortExpression == ''){
			return 'ASC';
        }
		else{
			return sortDirection;
        }
	}

	public void setSortDirection(String value){  
		sortDirection = value;
	}

	public PageReference ViewData(){
		String sortFullExp = sortExpression  + ' ' + sortDirection;
		items = Database.query('SELECT Id, Name, Type__c,Quantity__c,ProductionDate__c,Price__c,InStock__c,AddDate__c,Image__c FROM Item__c  order by ' + sortFullExp);
		return null;
	}

 
Rajesh3699Rajesh3699
Hey 

You want to write the test class for this complete class..? If not can you specify the method for which you want the test class..?

Thank You,
Rajesh.
Egor PalatovEgor Palatov
Hi Rajesh369. i Want to write test class for this complete class/
Rajesh3699Rajesh3699
Hello Egor, 

Can you post the complete class...? 
What ever you have posted is all the method..

Thank You.
Rajesh.