I have to find and solve a problem containing a circular dependency where I either store opaque pointers between the objects involved or use a separate class on a higher level to realize the relationship between the objects.
So I figured a simple problem where I have two classes, bank and account should do. The bank contains a list with accounts and the account contains a pointer to its bank. Circular dependency achieved.
But there is another condition which I have to satisfy which is that I have to make sure that the classes and the relationship between them can be tested independent of eachother.
The Bank class uses functions which do stuff on accounts, for example transfer funds between them, withdraw or add funds. And the account contains similar functions which edits its variables.
Testing the account class is easy as instantiating the class and test the functions but how can I test a class which depends on another class independent from the dependency? And how do you test a relationship between two classes?
I'm having trouble finding information on circular dependencies other than that you should avoid them but in larger projects they can be hard to avoid.