Monday, 21 November 2016

@isTest

public class TSBankContactCreate_Test2{


 static testMethod void myUnitTest1() {
    




String strRecordTypeId = [Select Id From RecordType Where SobjectType = 'Contact' and Name = 'Partner Contact'].Id;

 
//Insert Bank__c record
Bank__c bnk = new Bank__c();
bnk.Name = 'IDBI';
insert bnk;
ApexPages.currentPage().getParameters().put('Id',bnk.id);
User uname=[Select Id,Name,profile.Name from User Where profile.Name ='SYSADMIN_CAJ2' AND isActive=true limit 1];
Contact newContact = new Contact(
                  LastName = 'Test',
                  RecordTypeId = strRecordTypeId,
                  Bank__c=bnk.id,
                  Invisible_Bank__c=bnk.id
                 );
                insert newContact;
                   // load the extension
       // TSBankContactCreateExtention oCEE = new TSBankContactCreateExtention (new ApexPages.StandardController(contact));
    List<Contact> accountList = [SELECT Id FROM Contact where Id = : newContact.Id];            
//ApexPages.StandardController sc = new ApexPages.StandardController(accountList);
ApexPages.StandardSetController sc = new ApexPages.StandardSetController(accountList);
 TSBankContactCreateExtention TSBCon = new TSBankContactCreateExtention(sc);

System.runAs(uname) 
{
Test.StartTest();   
TSBCon.autoRun();
Test.StopTest();
}
}
/*
 static testMethod void myUnitTest2() {
 //ApexPages.StandardController sc = new ApexPages.StandardController(/apex/TSBankContactCreate);
 //TSBankContactCreateExtention TSBCon = new TSBankContactCreateExtention(sc);
    
String strRecordTypeId = [Select Id From RecordType Where SobjectType = 'Contact' and Name = 'Partner Contact'].Id;

 
//Insert Bank__c record
Bank__c bnk = new Bank__c();
bnk.Name = 'IDBI';
insert bnk;

//Insert Branch__c record
Branch__c brnch = new Branch__c();
brnch.Name = 'AP';
brnch.Bank__c=bnk.id;
insert brnch;

ApexPages.currentPage().getParameters().put('Id',brnch.id);
User uname=[Select Id,Name,profile.Name from User Where profile.Name ='SYSADMIN_CAJ2' AND isActive=true limit 1];

Contact newContact = new Contact(
                  LastName = 'Test',
                  RecordTypeId = strRecordTypeId,
                  Bank_Branch__c=brnch.id,
                  Bank__c=brnch.Bank__c
                 );
                insert newContact;
                
ApexPages.StandardController sc = new ApexPages.StandardController(newContact);
 TSBankContactCreateExtention TSBCon = new TSBankContactCreateExtention(sc);

System.runAs(uname) {
Test.StartTest();   
TSBCon.autoRun();
Test.StopTest();

}
}

 static testMethod void myUnitTest3() {
    
//ApexPages.StandardController sc = new ApexPages.StandardController(/apex/TSBankContactCreate);
      //  TSBankContactCreateExtention TSBCon = new TSBankContactCreateExtention(sc);

String strRecordTypeId = [Select Id From RecordType Where SobjectType = 'Contact' and Name = 'Partner Contact'].Id;

//Insert Bank__c record
Bank__c bnk = new Bank__c();
bnk.Name = 'IDBI';
insert bnk; 
//Insert Referral_Partner_Boarding__c record
Referral_Partner_Boarding__c Rpb = new Referral_Partner_Boarding__c();
Rpb.Name = 'RefferalName';
Rpb.Converted_Bank__c=bnk.id;
insert Rpb;

ApexPages.currentPage().getParameters().put('Id',Rpb.id);
User uname=[Select Id,Name,profile.Name from User Where profile.Name ='SYSADMIN_CAJ2' AND isActive=true limit 1];

Contact newContact = new Contact(
                  LastName = 'Test',
                  RecordTypeId = strRecordTypeId,
                  Bank__c=Rpb.Converted_Bank__c,
                   Referral_Partner_Boarding__c=Rpb.id
                 );
                insert newContact;
ApexPages.StandardController sc = new ApexPages.StandardController(newContact);
 TSBankContactCreateExtention TSBCon = new TSBankContactCreateExtention(sc);

System.runAs(uname) {
Test.StartTest();   
TSBCon.autoRun();
Test.StopTest();

}

}*/

}

No comments:

Post a Comment