-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMockSqlExecutor.cpp
More file actions
69 lines (51 loc) · 1.55 KB
/
MockSqlExecutor.cpp
File metadata and controls
69 lines (51 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "stdafx.h"
#include "MockSqlExecutor.h"
#include "MockDataReader.h"
MockSqlExecutor::MockSqlExecutor() :
_numberOfRecords(1)
{
}
MockSqlExecutor::MockSqlExecutor(const MockSqlExecutor &other) :
_numberOfRecords(other._numberOfRecords)
, _statement(other._statement)
, _columnValues(other._columnValues)
{
}
MockSqlExecutor::~MockSqlExecutor()
{
}
MockSqlExecutor &MockSqlExecutor::operator =(const MockSqlExecutor &other)
{
if (this != &other)
{
_numberOfRecords = other._numberOfRecords;
_statement = other._statement;
_columnValues = other._columnValues;
}
return *this;
}
std::shared_ptr<IDataReader> MockSqlExecutor::ExecuteReader(const std::shared_ptr<odbc::environment> &environment, const std::string &connectionString, const orm::sql::statement &statement) const
{
environment;
connectionString;
MockSqlExecutor *e = const_cast<MockSqlExecutor *>(this);
e->_statement = statement;
std::shared_ptr<IDataReader> reader = std::make_shared<MockDataReader>(_columnValues, _numberOfRecords);
return reader;
}
std::uint32_t MockSqlExecutor::ExecuteSql(const std::shared_ptr<odbc::environment> &environment, const std::string &connectionString, const orm::sql::statement &statement) const
{
environment;
connectionString;
MockSqlExecutor *e = const_cast<MockSqlExecutor *>(this);
e->_statement = statement;
return 0;
}
void MockSqlExecutor::SetColumnValue(const std::string &column, const std::int32_t value)
{
_columnValues[column] = value;
}
orm::sql::statement MockSqlExecutor::GetLastStatement() const
{
return _statement;
}