+ Start a Discussion
harsha vardhan vasa 9harsha vardhan vasa 9 

need a class for test class written pls help guys :

Hi guys ,
need to write a class for the test class attached. please help me asap:
    static void insertTest01() {
        ContractSheet__c contract = new ContractSheet__c();
        contract.Name = 'Contract1';
        insert contract;
        Account acc1 = new Account();
        acc1.Name = 'Acc1';
        Account acc2 = new Account();
        acc2.Name = 'Acc2';
        insert new List<Account>{acc1, acc2};
        AccountContract__c accCon1 = new AccountContract__c();
        accCon1.Contract__c = contract.Id;
        accCon1.Account__c = acc1.Id;
        AccountContract__c accCon2 = new AccountContract__c();
        accCon2.Contract__c = contract.Id;
        accCon2.Account__c = acc2.Id;

        insert new List<AccountContract__c>{accCon1, accCon2};

        contract = [SELECT ContractPartner__c FROM ContractSheet__c WHERE Id =: contract.Id];
        system.assertEquals(acc1.Name + ', ' + acc2.Name, contract.ContractPartner__c);

Vasa Harsha Vardhan.
Raj VakatiRaj Vakati
Its a practice to write the test class for the class .. not the class for the test class  .. 

Can you explain what you are trying to do 
harsha vardhan vasa 9harsha vardhan vasa 9
@raj Vakati,
thaks for the time. i know the process but in my project we have to do this. no other way.
Requirement: 3 objects - Account(parent),contractsheet(child),accountcontract(connected obj)
Get the company Name(field Name)of the company from (Account__c) that is linked to the contract(ContractSheet__c)via the contract execution destination(AccountContract__c), and update the account name  to the field(ContractPartner__c)of the contract record.
- if there are multiple names linked to the contractsheet__c those names should be concatenated by comma symbol 
Vasa Harsha Vardhan.