Database System 0.1.0
Advanced C++20 Database System with Multi-Backend Support
Loading...
Searching...
No Matches
database::testing::backend_expectation_builder Class Reference

Fluent builder for backend expectations. More...

#include <mock_backend_expectations.h>

Collaboration diagram for database::testing::backend_expectation_builder:
Collaboration graph

Public Member Functions

 backend_expectation_builder (mock_backend *db, backend_expectation exp)
 
backend_expectation_builderwill_return (const core::database_result &result)
 
backend_expectation_builderwill_return_rows (uint64_t count)
 
backend_expectation_builderwill_fail (const std::string &error_message)
 
backend_expectation_builderwill_succeed ()
 
backend_expectation_buildertimes (int count)
 
backend_expectation_builderonce ()
 
backend_expectation_builderany_times ()
 

Private Attributes

mock_backenddb_
 
backend_expectation exp_
 
bool pushed_ = false
 

Detailed Description

Fluent builder for backend expectations.

Definition at line 92 of file mock_backend_expectations.h.

Constructor & Destructor Documentation

◆ backend_expectation_builder()

database::testing::backend_expectation_builder::backend_expectation_builder ( mock_backend * db,
backend_expectation exp )

Definition at line 137 of file mock_backend_expectations.cpp.

Member Function Documentation

◆ any_times()

backend_expectation_builder & database::testing::backend_expectation_builder::any_times ( )

Definition at line 186 of file mock_backend_expectations.cpp.

186 {
187 exp_.at_least(0);
188 if (pushed_) {
189 db_->expectations_.back().at_least(0);
190 }
191 return *this;
192}
std::vector< backend_expectation > expectations_

References database::testing::backend_expectation::at_least(), db_, exp_, database::testing::mock_backend::expectations_, and pushed_.

Here is the call graph for this function:

◆ once()

backend_expectation_builder & database::testing::backend_expectation_builder::once ( )

Definition at line 178 of file mock_backend_expectations.cpp.

178 {
179 exp_.once();
180 if (pushed_) {
181 db_->expectations_.back().once();
182 }
183 return *this;
184}

References db_, exp_, database::testing::mock_backend::expectations_, database::testing::backend_expectation::once(), and pushed_.

Here is the call graph for this function:

◆ times()

backend_expectation_builder & database::testing::backend_expectation_builder::times ( int count)

Definition at line 170 of file mock_backend_expectations.cpp.

170 {
171 exp_.times(count);
172 if (pushed_) {
173 db_->expectations_.back().times(count);
174 }
175 return *this;
176}

References db_, exp_, database::testing::mock_backend::expectations_, pushed_, and database::testing::backend_expectation::times().

Here is the call graph for this function:

◆ will_fail()

backend_expectation_builder & database::testing::backend_expectation_builder::will_fail ( const std::string & error_message)

Definition at line 156 of file mock_backend_expectations.cpp.

156 {
157 exp_.returning_error(error_message);
158 db_->expectations_.push_back(exp_);
159 pushed_ = true;
160 return *this;
161}
backend_expectation & returning_error(const std::string &error_message)

References db_, exp_, database::testing::mock_backend::expectations_, pushed_, and database::testing::backend_expectation::returning_error().

Referenced by database::testing::mock_backend_builder::failing_database().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ will_return()

backend_expectation_builder & database::testing::backend_expectation_builder::will_return ( const core::database_result & result)

Definition at line 142 of file mock_backend_expectations.cpp.

142 {
143 exp_.returning(result);
144 db_->expectations_.push_back(exp_);
145 pushed_ = true;
146 return *this;
147}
backend_expectation & returning(const core::database_result &result)

References db_, exp_, database::testing::mock_backend::expectations_, pushed_, and database::testing::backend_expectation::returning().

Referenced by database::testing::mock_backend_builder::with_data().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ will_return_rows()

backend_expectation_builder & database::testing::backend_expectation_builder::will_return_rows ( uint64_t count)

Definition at line 149 of file mock_backend_expectations.cpp.

149 {
151 db_->expectations_.push_back(exp_);
152 pushed_ = true;
153 return *this;
154}
backend_expectation & returning_rows_affected(uint64_t count)

References db_, exp_, database::testing::mock_backend::expectations_, pushed_, and database::testing::backend_expectation::returning_rows_affected().

Here is the call graph for this function:

◆ will_succeed()

backend_expectation_builder & database::testing::backend_expectation_builder::will_succeed ( )

Definition at line 163 of file mock_backend_expectations.cpp.

163 {
165 db_->expectations_.push_back(exp_);
166 pushed_ = true;
167 return *this;
168}

References db_, exp_, database::testing::mock_backend::expectations_, pushed_, and database::testing::backend_expectation::returning_execute_success().

Here is the call graph for this function:

Member Data Documentation

◆ db_

mock_backend* database::testing::backend_expectation_builder::db_
private

◆ exp_

backend_expectation database::testing::backend_expectation_builder::exp_
private

◆ pushed_

bool database::testing::backend_expectation_builder::pushed_ = false
private

The documentation for this class was generated from the following files: