apex-enterprise-patterns / force-di

Generic DI library with support for Apex, Triggers, Visualforce and Lightning
BSD 3-Clause "New" or "Revised" License
229 stars 100 forks source link

Fix for test method givenApexBindingWhenGetNewInstanceThenNewInstance #72

Closed smukov closed 3 years ago

smukov commented 3 years ago

This is a small fix for PR #71 where an override for instance caching was implemented.

The error was that the getInstance(Object params) was being invoked in the failing test method instead of the getInstance(Object params, Boolean newInstance). This caused the params to not be null, and so the code expected that the created instance was an implementation of a Provider, which it wasn't.

See below the error message and the stack trace of the failing test:

di_Binding.BindingException: Apex binding di_BindingTest.Bob implementation di_BindingTest.Bob does not implement the Provider interface.

Class.di_Binding.ApexBinding.newInstance: line 413, column 1
Class.di_Binding.getInstance: line 82, column 1
Class.di_Binding.getInstance: line 70, column 1
Class.di_BindingTest.givenApexBindingWhenGetNewInstanceThenNewInstance: line 53, column 1

This change is Reviewable