Created
September 20, 2020 19:35
-
-
Save atimin/eb340014bd90aeda895a7d7621d3312b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ISmartObject { | |
public: | |
virtual int Foo() const = 0; | |
} | |
class RealObject : public ISmartObject { | |
public: | |
RealObject() { /* allocate resource and throw exception */ } | |
int Foo() const override { /* do real work */ } | |
} | |
class MockObject : public ISmartObject { | |
public: | |
int Foo() const override { /* do nothing */ } | |
} | |
class ClientObject { | |
public: | |
ClientObject(); | |
UseSmartObject(const ISmartObject& obj); // Use interface not implementation! | |
} | |
// Somewhere in test | |
ClientObject obj; | |
obj.UseSmartObject(MockObject()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment