Andy in the Cloud

From BBC Basic to and beyond…

4 thoughts on “Test Driven Development, Mocking and Force DI

  1. Where does the module class get instantiated in the basic scenario of an apex controller referencing/instantiating one or more service classes?

    public with sharing class MyController {
    private MyFirstService firstService;
    private MySecondService secondService;

    public MyController() {
    firstService = (MyFirstService) di_Injector.Org.getInstance(MyFirstService.class);

    secondService = (MySecondService) di_Injector.Org.getInstance(MySecondService.class);

    public class MyServicesConfiguration extends di_Module {

    public override void configure() {

    // Configure binding

    • The bootstrapping code that executes when the injector is first references uses the Custom Metadata Bindings to look for Modules that have been registered with it. So basically register your module with the Binding Custom Metadata type and you should be good! 🙂

  2. Pingback: Test Driven Development, Mocking and Force DI — Andy in the Cloud – SutoCom Solutions

  3. Pingback: Test Driven Development, Mocking and Force DI - Salesforce News & Tutorials

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s