Snippets

Tim Schuitemaker testDimensionJunctions

Created by Tim Schuitemaker last modified
@IsTest
private class Test_B25_Reservation {

    @isTest private static void testDimensionJunctions() {
        B25__Reservation__c reservation = new B25__Reservation__c();
        reservation.B25__Start__c = DateTime.now();
        reservation.B25__End__c = DateTime.now().addHours(1);
        Database.insert(reservation);

        <YOUROBJECT>__c yourobject = new <YOUROBJECT>__c(); //replace this with the name of your object
        yourobject.Name ='a'; // if this is field is an auto number you dont need this.
        Database.insert(yourobject);

        Reservation_<YOUROBJECT>__c resYourobject = new Reservation_<YOUROBJECT>__c(); //replace Reservation_<YOUROBJECT>__c with the name of your dimension junction object
        resYourobject.Reservation__c = reservation.Id;
        resYourobject.<YOUROBJECT>__c = yourobject.Id; //replace this with the name of the lookup on the dimension junction
        Database.insert(resYourobject);

        System.assertEquals(1, [SELECT Id FROM B25__Reservation__c].size());
    }  
}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.