Custom Metadata Type:
Custom Metadata Type Data:
Sample Apex class and test class:
public class Sample {
public static Sample__mdt getSampleValue( String strName ) {
return [ SELECT DeveloperName, Description__c FROM Sample__mdt WHERE DeveloperName =: strName ];
}
}
@isTest
public class SampleTest {
static testMethod void test() {
Sample__mdt objSample = Sample.getSampleValue('Test');
system.assertEquals('Test', objSample.DeveloperName);
system.assertEquals('Test', objSample.Description__c);
}
}
Output: