+ Start a Discussion
Mike Schumacher 2Mike Schumacher 2 

pass wrapper class to another method

I have a wrapper class defined and a method that is expecting a <list> of the wrapper class.  I get the error 'method does not exist or incorrect signature: void methodname<list>.......

Here is the simple class:
public class Test_ClassWrapper {
    public static void miketest3(List<MikeRecordWrapper> mRecord) {
        System.debug('....in miketest3 routine');
    }
    
    public class MikeRecordWrapper {
        public String Mike1;
        public String Mike2;
    }

}

When I create a test class to pass a wrapper list I receive my compliation error message.

Test Script:
@isTest (SeeAllData=true)
public class Test_ClassWrapper_Test {

    static testMethod void Test_ClassWrapper_Test() {
        
        MikeRecordWrapper mr = new MikeRecordWrapper();
        mr.Mike1 = 'test';
        mr.Mike2 = 'test2';
        //create my wrapper list
        List<MikeRecordWrapper> mikerecordList = new List<MikeRecordWrapper>();
        mikerecordList.add(mr);
        Test_ClassWrapper.miketest3( mikerecordList);
    }
   
    public class MikeRecordWrapper {
        public String Mike1;
        public String Mike2;
    }

}

I get the error on line "Test_ClassWrapper.miketest3( mikerecordList);"

Error:
Method does not exist or incorrect signature: void miketest3(List<Test_ClassWrapper_Test.MikeRecordWrapper>) from the type Test_ClassWrapper

If I change the classes to just pass a simple list of strings no error message.  I thought I could then pass a list of my custom wrapper.

Any asistance is appreciated.

Thanks
Mike
 
Mike Schumacher 2Mike Schumacher 2
I had to redo my test script and reference the wrapper class directly.  I thought I would be able to create a class wrapper in my test script and then pass the wrapper and the values.    I still not sure I understand completely why I have to code it this way, but I do have my test script working.  If someone still has an explanation or a link I should go read, I am happy to review it.

thanks, Mike


@isTest (SeeAllData=true)
public class Test_ClassWrapper_Test {

    static testMethod void Test_ClassWrapper_Test() {
        
        Test_ClassWrapper.MikeRecordWrapper mr = new Test_ClassWrapper.MikeRecordWrapper();
        mr.Mike1 = 'test';
        mr.Mike2 = 'test2';
        List<Test_ClassWrapper.MikeRecordWrapper> mikerecordList = new List<Test_ClassWrapper.MikeRecordWrapper>();
        mikerecordList.add(mr);
        //Test_ClassWrapper tcw = new Test_ClassWrapper();
        Test_ClassWrapper.miketest3( mr);
        
    }

//removed the MikeRecordWrapper class from the test script
}