// Memory.h
#include "Block.h"
namespace User{
class Memory
{
protected:
Block block_instance;
public:
BlockList* GetBlockList();
};
}
// Memory.cpp
#include "Memory.h"
namespace User{
const BlockList* Memory::GetBlockList()
{
return block_instance.GetList();
}
}
I want to test GetBlockList from Memory class with gtest, but I suppose I need to use gmock to mocking Block Class. block_instance is protected variable and I suppose use EXPECT_CALL for its return value. How can we mock this scenario, how can we write test for it ?
I tried to define interface but I can't access to block_instance. I had build errors. I can not imagine how can I access to block_instance and test the return value of it in other method.
I would expect something along these lines (with dependency injection)