+ Start a Discussion
fiona gentryfiona gentry 

Need a test class for Lookup class

Hi Gurus,

Please provide me a test class for below look up class
 
/**
* Class used to serialize a single Lookup search result item
* The Lookup controller returns a List<LookupSearchResult> when sending search result back to Lightning
*/
public class LookupSearchResult {

    private Id id;
    private String sObjectType;
    private String icon;
    private String title;
    private String subtitle;

    public LookupSearchResult(Id id, String sObjectType, String icon, String title, String subtitle) {
        this.id = id;
        this.sObjectType = sObjectType;
        this.icon = icon;
        this.title = title;
        this.subtitle = subtitle;
    }

    @AuraEnabled
    public Id getId() {
        return id;
    }

    @AuraEnabled
    public String getSObjectType() {
        return sObjectType;
    }

    @AuraEnabled
    public String getIcon() {
        return icon;
    }

    @AuraEnabled
    public String getTitle() {
        return title;
    }

    @AuraEnabled
    public String getSubtitle() {
        return subtitle;
    }
}

Regards,
Fiona​​​​​​​
Best Answer chosen by fiona gentry
GulshanRajGulshanRaj
Hi Fiona,

Here we go
@isTest
public class TestLookupSearchResult {
    public static  testMethod void testCallClass(){
		Account acc = new Account(Name='Test Account');
        insert acc;
        Test.startTest();
        LookupSearchResult lcr = new LookupSearchResult(acc.id,'Account','Test Icon','Test Title','Test Sub-Title');
        system.assert(lcr.getId() == acc.id);
        system.assert(lcr.getSObjectType() == 'Account');
        system.assert(lcr.getIcon() == 'Test Icon');
        system.assert(lcr.getTitle() == 'Test Title'); 
        system.assert(lcr.getSubtitle() == 'Test Sub-Title'); 
        Test.stopTest();
    }
}

Thanks 
Gulshan Raj 
https://www.linkedin.com/in/gulshan-raj