B25.Test_FormHelper.TestFormContext
Overview
Object that is used to specify the form context inside of unit tests.
To test your custom form API implementation you need to be able to specify the state of the form when the event handlers are fired. This class contains this state.
Example
B25.Test_FormHelper.TestFormContext formContext = new B25.Test_FormHelper.TestFormContext();
formContext.reservation = new B25__Reservation__c(
B25__StartLocal__c = Datetime.now(),
B25__EndLocal__c = Datetime.now().addHours(1)
);
formContext.relatedSObjects.put('B25__ReservationContact__c', new List<SObject>{
new B25__ReservationContact__c()
});
Properties
Name | Type | Description |
---|---|---|
reservation | B25__Reservation__c | The reservation on the form during the firing of the event. |
relatedSObjects | Map<String, List<SObject>> | The related lists on the form during the firing of the events. |
Methods
getNewFormRecord
Using this method you can get a FormRecord to use as context. You can then use the same methods you would use to set fields and related records in the Custom Form Logic to create the context.
These records can then be used to set the parent active and child records.
FormRecord getNewFormRecord(Reservation__c reservation)
Return value: FormRecord
Parameters:
Name | Type | Description |
---|---|---|
reservation | B25__Reservation__c | The reservation that should be the base of this FormRecord. |
setActiveRecord
Setting the active record disables the reservation and relatedSObjects properties. Use the FormRecord instead to set the values and related records.
Sets the contexts active record to the given FormRecord
FormRecord setActiveRecord(FormRecord activeRecord)
Parameters:
Name | Type | Description |
---|---|---|
activeRecord | The FormRecord to use as active record. |
setParentRecord
Sets the contexts parent record to the given FormRecord
Parameters:
Name | Type | Description |
---|---|---|
parentRecord | The FormRecord to use as parent record. |
addChildRecord
Adds the given FormRecord to the list of child records for this context.
Parameters:
Name | Type | Description |
---|---|---|
childRecord | The FormRecord to add as child record. |