Example that shows the usage of the EnableGMock.h file.
#include "DataSourceUserTemplatedTypeMock.h"
using Elements::Examples::DataSourceUserTemplatedTypeMock;
using testing::Return;
BOOST_AUTO_TEST_SUITE(TemplatedDataSourceUser_test_suite)
BOOST_AUTO_TEST_CASE(sumRecords_test) {
DataSourceUserTemplatedTypeMock data_source_mock;
EXPECT_CALL(data_source_mock, countRecords()).Times(1).WillOnce(Return(5));
for (size_t index = 0; index < 5; ++index) {
EXPECT_CALL(data_source_mock, getRecordValue(index)).Times(1).WillOnce(Return(static_cast<double>(index) + 1.));
}
double result = user.
sumRecords<DataSourceUserTemplatedTypeMock>(data_source_mock);
BOOST_CHECK_MESSAGE(
Elements::isEqual(result, 15.),
"Expected value :" << 15 <<
" Actual value :" << result);
}
BOOST_AUTO_TEST_SUITE_END()