• WaqarAhmed
  • 0 Points
  • Member since 2021

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 4
I have written the Code for Test Class"TestRestrictContactByName'.
private class TestRestrictContactByName {
    @isTest static void testRestrictContacts(){
        Contact con1 = new Contact(FirstName='Htesh', LastName='khatri');
        Database.SaveResult Result = Database.insert(con1,false);
        System.assertEquals('The Last Name "'+con1.LastName+'" is not allowed for DML',result.getErrors()[0].getMessage());
    After Running this test i am getting an error 'Challenge not yet complete... here's what's wrong:
The 'RestrictContactByName' class did not achieve 100% code coverage via your test methods' .

Please help me in solving this.
I am not able to understand the below question correctly Please help me out. - 
Create a class that has a method accepting two strings. The method searches for contacts that have a last name matching the first string and a mailing postal code (API name: MailingPostalCode) matching the second. It gets the ID and Name of those contacts and returns them.The Apex class must be called 'ContactSearch' and be in the public scope.
The Apex class must have a public static method called 'searchForContacts'.
The 'searchForContacts' method must accept two incoming strings as parameters, find any contact that has a last name matching the first, and mailing postal code matching the second string. The method should return a list of Contact records with at least the ID and Name fields.
The return type for 'searchForContacts' must be 'List<Contact>'.