# Class MockConnection (3.7.0-rc)

3.7.0-rc 3.6.0 (latest) 3.5.0 3.4.0 3.3.0 3.2.0 2.48.0-rc 2.47.1 2.46.0 2.45.0 2.44.0 2.43.0 2.42.0 2.41.0 2.40.0 2.39.0 2.38.0 2.37.0 2.36.0 2.35.0 2.34.0 2.33.0 2.32.0 2.31.0 2.30.0 2.29.0 2.28.0 2.27.0 2.26.0 2.25.1 2.24.0 2.23.0 2.22.1 2.21.0 2.20.0 2.19.0 2.18.0 2.17.0 2.16.0 2.15.1 2.14.0 2.13.0 2.12.0 2.11.0 An inlined versioned namespace to avoid dependency diamonds.
A class to mock [`google::cloud::spanner::Connection`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Connection).

Application developers may want to test their code with simulated responses, including errors from a [`spanner::Client`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client). To do so, construct a [`spanner::Client`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client) with an instance of this class. Then use the Google Test framework functions to program the behavior of this mock.

###### See Also

[Mocking the Cloud Spanner C++ Client with Google Mock](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/spanner-mocking) for an example using this class.

## Functions

### virtual options()

Returns the options used by the [Connection](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Connection).
This function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.
Consult the gMock documentation to use this mock in your tests.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Options` |   |

### virtual Read(ReadParams)

Defines the interface for [`Client::Read()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1a167955c44cd3ccb46ffe07cad6e7e52b)
This function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.
Consult the gMock documentation to use this mock in your tests.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `ReadParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `RowStream` |   |

### virtual PartitionRead(PartitionReadParams)

Defines the interface for [`Client::PartitionRead()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1a039dd1aa3b34ad3cbeda17d810809b17)
This function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.
Consult the gMock documentation to use this mock in your tests.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `PartitionReadParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `StatusOr< std::vector< ReadPartition > >` |   |

### virtual ExecuteQuery(SqlParams)

Defines the interface for [`Client::ExecuteQuery()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1a8e2afee42f535c0436d9161c54b84179)
This function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.
Consult the gMock documentation to use this mock in your tests.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `SqlParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `RowStream` |   |

### virtual ExecuteDml(SqlParams)

Defines the interface for [`Client::ExecuteDml()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1aec1b7d1cd45111126af5aa3b69c8eed0)
This function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.
Consult the gMock documentation to use this mock in your tests.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `SqlParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `StatusOr< DmlResult >` |   |

### virtual ProfileQuery(SqlParams)

Defines the interface for [`Client::ProfileQuery()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1abee0a6c093b2d7a645f899368b082eae)
This function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.
Consult the gMock documentation to use this mock in your tests.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `SqlParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `ProfileQueryResult` |   |

### virtual ProfileDml(SqlParams)

Defines the interface for [`Client::ProfileDml()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1a5628f7c60f46d6d49408245cd9fe8fc1)
This function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.
Consult the gMock documentation to use this mock in your tests.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `SqlParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `StatusOr< ProfileDmlResult >` |   |

### virtual AnalyzeSql(SqlParams)

Defines the interface for [`Client::AnalyzeSql()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1ad90737b8234c7ead6bc4e8273108f152)
This function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.
Consult the gMock documentation to use this mock in your tests.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `SqlParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `StatusOr< ExecutionPlan >` |   |

### virtual ExecutePartitionedDml(ExecutePartitionedDmlParams)

Defines the interface for [`Client::ExecutePartitionedDml()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1a0cbf8aebf8e345ec3acf0479c8674635)
This function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.
Consult the gMock documentation to use this mock in your tests.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `ExecutePartitionedDmlParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `StatusOr< PartitionedDmlResult >` |   |

### virtual PartitionQuery(PartitionQueryParams)

Defines the interface for [`Client::PartitionQuery()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1a4b99fa616d2f417c64621523b06a58cf)
This function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.
Consult the gMock documentation to use this mock in your tests.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `PartitionQueryParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `StatusOr< std::vector< QueryPartition > >` |   |

### virtual ExecuteBatchDml(ExecuteBatchDmlParams)

Defines the interface for [`Client::ExecuteBatchDml()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1a23079113b30a48efba6f9ab200e48752)
This function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.
Consult the gMock documentation to use this mock in your tests.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `ExecuteBatchDmlParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `StatusOr< BatchDmlResult >` |   |

### virtual Commit(CommitParams)

Defines the interface for [`Client::Commit()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1ae83521aef8045ac04b0a5dc85b08a2d9)
This function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.
Consult the gMock documentation to use this mock in your tests.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `CommitParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `StatusOr< CommitResult >` |   |

### virtual Rollback(RollbackParams)

Defines the interface for [`Client::Rollback()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1a2687b25e5090ae63e9521c93903a94a3)
This function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.
Consult the gMock documentation to use this mock in your tests.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `RollbackParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Status` |   |

### virtual BatchWrite(BatchWriteParams)

Defines the interface for batched [`Client::CommitAtLeastOnce()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1a3765eebf4b408b580d7d3ef9d7f52ed2)
This function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.
Consult the gMock documentation to use this mock in your tests.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `BatchWriteParams` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `BatchedCommitResultStream` |   |