2011-09-08 5 views
0

컨트롤러 확장을위한 테스트 클래스를 작성하려고합니다. 이 컨트롤러 확장에는 다른 클래스가 있습니다. 그리고이 수업에는 몇 가지 방법이 있습니다.컨트롤러 확장 클래스에있는 클래스 내의 메서드를 호출하는 방법?

public class Extension_Account 
{ 
    public Extension_Account(ApexPages.StandardController controller) 
    { 
     public class Class1 
     { 
     public Class1() 
     { 
     /* code here*/ 
     } 
     public String getMethod() 
     { 
     /* code here */ 
      } 
     } 
    } 
} 

내 테스트 클래스에서 getMethod 메소드에 액세스하려면 어떻게해야합니까? 내 테스트 클래스에서

내가 다른 방법에 도착하는 방법을 잘 클래스 1의 생성자에 액세스 할 수 있지만 나는

확장 클래스는 클래스 1의 인스턴스를 반환하는 getClass1() 메소드가
public with sharing class TestExtension_Account 

{ 
    static testMethod void TestPrint() 
    { 
     Account a = new Account(); 
     //a.Name='Test Account'; 
     a.FirstName='TestFirst Name'; 
     a.LastName='Test Last Name'; 
     a.BillingStreet='Test billing Street'; 
     a.BillingCity='Test Billing City'; 
     a.BillingState='Test Billing State'; 
     a.BillingCountry='Test Billing country'; 
     a.BillingPostalCode='Test PostCode'; 
     insert a; 



     PageReference pageRef = Page.printaddressaccount; 
     pageRef .getParameters().put('id',a.id); 
     Test.setCurrentPageReference(pageRef); 
     ApexPages.StandardController controller = new ApexPages.StandardController(a); 
     Extension_Account ae = new Extension_Account(controller); 
     ae.getClass1(); 
     ae.getMethod()// gives a compiler error Method does not exist or incorrect signature 
} 
} 

답변

0

경우 , 그 인스턴스에서 메서드에 액세스 할 수 있습니다 (예 : ae.getClass1().getMethod();

+0

감사합니다. 수퍼 펠, 나는 매력처럼 일했습니다. – Prady

관련 문제