Skip to content

Instantly share code, notes, and snippets.

@bkuhns
Last active December 12, 2015 09:19
Show Gist options
  • Save bkuhns/4750954 to your computer and use it in GitHub Desktop.
Save bkuhns/4750954 to your computer and use it in GitHub Desktop.
#include "IDbService.h"
class AdoService : public IDbService {
public:
static AdoService& instance() override;
QueryResult runQuery(string query) override;
};
#include "AdoService.h"
class DataModel : public Persistable {
public:
DataModel(DbService& dbService = AdoService::instance());
private:
PersistenceReport readData() override;
};
class IDbService {
public:
static IDbService& instance() = 0;
QueryResult runQuery(string query) = 0;
};
#include "DataModel.h"
#include "MockDbService.h"
int main() {
DataModel model;
DataModel testModel(MockDbService::instance());
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment