• John Guerriere
  • NEWBIE
  • 10 Points
  • Member since 2019
  • Charleston Nonprofit Community Leader


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 5
    Replies
Hi there,

Below is my test class where the SearchMembers method fails: System.AssertException: Assertion Failed: Expected: 4, Actual: 0

The testLoadData method passes....

Any help appreciated....
==
@isTest
private class MembershipDirectoryControllerTest {

    @testSetup static void createData() {
        List<Account> accounts = new List<Account>();
        Account a1 = new Account();
        a1.Name = 'Test 1';
        a1.Membership_Level__c = 'Catalyst';
        a1.Category__c = 'Farms';
        a1.Keywords__c = 'farm';
        a1.BillingPostalCode = '11111';
        a1.Directory_Display_Override__c = true;
        accounts.add(a1);

        Account a2 = new Account();
        a2.Name = 'Test 2';
        a2.Membership_Level__c = 'Champion';
        a2.Category__c = 'Education';
        a2.Keywords__c = 'test';
        a2.BillingPostalCode = '22222';
        a2.Directory_Display_Override__c = true;
        accounts.add(a2);

        Account a3 = new Account();
        a3.Name = 'Test 3';
        a3.Membership_Level__c = 'Catalyst';
        a3.Category__c = 'Farms';
        a3.Keywords__c = 'farm';
        a3.BillingPostalCode = '11111';
        a3.Directory_Display_Override__c = true;
        accounts.add(a3);

        Account a4 = new Account();
        a4.Name = 'Test 4';
        a4.Membership_Level__c = 'Champion';
        a4.Category__c = 'Business Supplies';
        a4.Keywords__c = 'farm';
        a4.BillingPostalCode = '22222';
        a4.Directory_Display_Override__c = true;
        accounts.add(a4);

        Account a5 = new Account();
        a5.Name = 'Test 5';
        a5.Membership_Level__c = 'Catalyst';
        a5.Category__c = 'Farms';
        a5.Keywords__c = 'test';
        a5.BillingPostalCode = '11111';
        a5.Directory_Display_Override__c = true;
        accounts.add(a5);

        Account a6 = new Account();
        a6.Name = 'Test 6';
        a6.Membership_Level__c = 'Champion';
        a6.Category__c = 'Personal Services';
        a6.Keywords__c = 'farm';
        a6.BillingPostalCode = '22222';
        a6.Directory_Display_Override__c = true;
        accounts.add(a6);

        Account a7 = new Account();
        a7.Name = 'Test 7';
        a7.Membership_Level__c = 'Business';
        a7.Category__c = 'Farms';
        a7.Keywords__c = 'test';
        a7.BillingPostalCode = '11111';
        a7.Directory_Display_Override__c = true;
        accounts.add(a7);

        insert accounts;
    }
  
  @isTest static void testLoadData() {
    Test.startTest();
        MembershipDirectoryModels.FormData fd = MembershipDirectoryController.loadData();
        Test.stopTest();

        System.assertNotEquals(null, fd.categories);
        System.assertEquals(6, fd.spotlightMembers.size());
  }
  
  @isTest static void testSearchMembers() {
    Test.startTest();
        List<Account> categorySearch = MembershipDirectoryController.searchMembers('category', 'Farms');
        List<Account> nameLetterSearch = MembershipDirectoryController.searchMembers('name', 'T');
        List<Account> nameSearch = MembershipDirectoryController.searchMembers('nameSearch', 'Test 3');
        List<Account> keywordSearch = MembershipDirectoryController.searchMembers('keyword', 'test');
        List<Account> zipCodeSearch = MembershipDirectoryController.searchMembers('zipCode', '11111');
        Test.stopTest();

        System.assertEquals(4, categorySearch.size());
        System.assertEquals(7, nameLetterSearch.size());
        System.assertEquals(1, nameSearch.size());
        System.assertEquals(3, keywordSearch.size());
        System.assertEquals(4, zipCodeSearch.size());
  }
  
}


 
Hi there,

Below is my test class where the SearchMembers method fails: System.AssertException: Assertion Failed: Expected: 4, Actual: 0

The testLoadData method passes....

Any help appreciated....
==
@isTest
private class MembershipDirectoryControllerTest {

    @testSetup static void createData() {
        List<Account> accounts = new List<Account>();
        Account a1 = new Account();
        a1.Name = 'Test 1';
        a1.Membership_Level__c = 'Catalyst';
        a1.Category__c = 'Farms';
        a1.Keywords__c = 'farm';
        a1.BillingPostalCode = '11111';
        a1.Directory_Display_Override__c = true;
        accounts.add(a1);

        Account a2 = new Account();
        a2.Name = 'Test 2';
        a2.Membership_Level__c = 'Champion';
        a2.Category__c = 'Education';
        a2.Keywords__c = 'test';
        a2.BillingPostalCode = '22222';
        a2.Directory_Display_Override__c = true;
        accounts.add(a2);

        Account a3 = new Account();
        a3.Name = 'Test 3';
        a3.Membership_Level__c = 'Catalyst';
        a3.Category__c = 'Farms';
        a3.Keywords__c = 'farm';
        a3.BillingPostalCode = '11111';
        a3.Directory_Display_Override__c = true;
        accounts.add(a3);

        Account a4 = new Account();
        a4.Name = 'Test 4';
        a4.Membership_Level__c = 'Champion';
        a4.Category__c = 'Business Supplies';
        a4.Keywords__c = 'farm';
        a4.BillingPostalCode = '22222';
        a4.Directory_Display_Override__c = true;
        accounts.add(a4);

        Account a5 = new Account();
        a5.Name = 'Test 5';
        a5.Membership_Level__c = 'Catalyst';
        a5.Category__c = 'Farms';
        a5.Keywords__c = 'test';
        a5.BillingPostalCode = '11111';
        a5.Directory_Display_Override__c = true;
        accounts.add(a5);

        Account a6 = new Account();
        a6.Name = 'Test 6';
        a6.Membership_Level__c = 'Champion';
        a6.Category__c = 'Personal Services';
        a6.Keywords__c = 'farm';
        a6.BillingPostalCode = '22222';
        a6.Directory_Display_Override__c = true;
        accounts.add(a6);

        Account a7 = new Account();
        a7.Name = 'Test 7';
        a7.Membership_Level__c = 'Business';
        a7.Category__c = 'Farms';
        a7.Keywords__c = 'test';
        a7.BillingPostalCode = '11111';
        a7.Directory_Display_Override__c = true;
        accounts.add(a7);

        insert accounts;
    }
  
  @isTest static void testLoadData() {
    Test.startTest();
        MembershipDirectoryModels.FormData fd = MembershipDirectoryController.loadData();
        Test.stopTest();

        System.assertNotEquals(null, fd.categories);
        System.assertEquals(6, fd.spotlightMembers.size());
  }
  
  @isTest static void testSearchMembers() {
    Test.startTest();
        List<Account> categorySearch = MembershipDirectoryController.searchMembers('category', 'Farms');
        List<Account> nameLetterSearch = MembershipDirectoryController.searchMembers('name', 'T');
        List<Account> nameSearch = MembershipDirectoryController.searchMembers('nameSearch', 'Test 3');
        List<Account> keywordSearch = MembershipDirectoryController.searchMembers('keyword', 'test');
        List<Account> zipCodeSearch = MembershipDirectoryController.searchMembers('zipCode', '11111');
        Test.stopTest();

        System.assertEquals(4, categorySearch.size());
        System.assertEquals(7, nameLetterSearch.size());
        System.assertEquals(1, nameSearch.size());
        System.assertEquals(3, keywordSearch.size());
        System.assertEquals(4, zipCodeSearch.size());
  }
  
}


 
So I found a formula in this link that solves 75% of my formatting problems in salesforce (https://developer.salesforce.com/forums/ForumsMain?id=906F0000000927nIAA)

The problem is it's limited to the first three set of text queries in a field (e.g. John Deere Green but a fourth word like tractors wouldn't be impacted). I'm trying to figure out how to expand it past three words. Any help? The biggest impact this would have is in the address field (4242 John Wayne street). It'd be great to capitalize the S of street in that field.
How to count number of options selected from multiselect picklist

Has anyone ever created a formula to proper case fields?

 

Thank you,

Steve