-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Labels
enhancementNew feature or requestNew feature or requestrequirements:high changeThis code introduces a significant changes to the requirements for the projectThis code introduces a significant changes to the requirements for the projectrequirements:low changeThis code introduces a small change in requirements for the projectThis code introduces a small change in requirements for the project
Description
The global DatabaseManager class makes it difficult to do testing using dependency inversion.
- Properties are read from a file rather than providing them to the manager.
- The singleton pattern makes it difficult to load different databases for different tests or to create and delete a database for a test.
- It forces the same database to be used for both testing and development.
- It forces tests to use introspection to implemented desired behavior at runtime.
- It encourages the exposure of a dangerous endpoint (
clear) in order to enable testing.
Most implementations are already passing a DataAccess object around and so there is little value in a DatabaseManager singleton. We should just initialize the DataAccess object with the desired DatabaseManager. Then a test could provide a mocked database version if desired, or set up and tear down a test database. You could get rid of the clear endpoint.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestrequirements:high changeThis code introduces a significant changes to the requirements for the projectThis code introduces a significant changes to the requirements for the projectrequirements:low changeThis code introduces a small change in requirements for the projectThis code introduces a small change in requirements for the project