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

Builder for common mock configurations. More...

#include <mock_backend.h>

Collaboration diagram for database::testing::mock_backend_builder:
Collaboration graph

Public Member Functions

 mock_backend_builder ()
 
mock_backend_builderwith_type (database_types type)
 
mock_backend_builderwith_default_result (const core::database_result &result)
 
mock_backend_builderthat_fails_on_initialize ()
 
mock_backend build ()
 

Static Public Member Functions

static mock_backend empty_database ()
 
static mock_backend with_data (const std::string &table_name, const core::database_result &data)
 
static mock_backend failing_database (const std::string &error="Mock database error")
 

Private Attributes

std::unique_ptr< mock_backendmock_
 

Detailed Description

Builder for common mock configurations.

Definition at line 130 of file mock_backend.h.

Constructor & Destructor Documentation

◆ mock_backend_builder()

database::testing::mock_backend_builder::mock_backend_builder ( )

Definition at line 259 of file mock_backend.cpp.

260 : mock_(std::make_unique<mock_backend>())
261{
262}
std::unique_ptr< mock_backend > mock_

Member Function Documentation

◆ build()

mock_backend database::testing::mock_backend_builder::build ( )

Definition at line 295 of file mock_backend.cpp.

295 {
296 return std::move(*mock_);
297}

References mock_.

◆ empty_database()

mock_backend database::testing::mock_backend_builder::empty_database ( )
static

Definition at line 264 of file mock_backend.cpp.

264 {
265 return mock_backend();
266}

Referenced by TEST_F().

Here is the caller graph for this function:

◆ failing_database()

mock_backend database::testing::mock_backend_builder::failing_database ( const std::string & error = "Mock database error")
static

Definition at line 274 of file mock_backend.cpp.

274 {
275 mock_backend db;
276 db.expect_any().will_fail(error);
277 return db;
278}

References database::testing::mock_backend::expect_any(), and database::testing::backend_expectation_builder::will_fail().

Referenced by TEST_F().

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

◆ that_fails_on_initialize()

mock_backend_builder & database::testing::mock_backend_builder::that_fails_on_initialize ( )

Definition at line 290 of file mock_backend.cpp.

290 {
291 mock_->simulate_initialization_failure();
292 return *this;
293}

References mock_.

◆ with_data()

mock_backend database::testing::mock_backend_builder::with_data ( const std::string & table_name,
const core::database_result & data )
static

Definition at line 268 of file mock_backend.cpp.

268 {
269 mock_backend db;
270 db.expect_pattern("SELECT.*FROM.*" + table_name).will_return(data);
271 return db;
272}

References database::testing::mock_backend::expect_pattern(), and database::testing::backend_expectation_builder::will_return().

Referenced by TEST_F().

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

◆ with_default_result()

mock_backend_builder & database::testing::mock_backend_builder::with_default_result ( const core::database_result & result)

Definition at line 285 of file mock_backend.cpp.

285 {
286 mock_->set_default_select_result(result);
287 return *this;
288}

References mock_.

◆ with_type()

mock_backend_builder & database::testing::mock_backend_builder::with_type ( database_types type)

Definition at line 280 of file mock_backend.cpp.

280 {
281 mock_->set_database_type(type);
282 return *this;
283}

References mock_.

Member Data Documentation

◆ mock_

std::unique_ptr<mock_backend> database::testing::mock_backend_builder::mock_
private

Definition at line 147 of file mock_backend.h.

Referenced by build(), that_fails_on_initialize(), with_default_result(), and with_type().


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