Application developers may want to test their code with simulated responses, including errors, from an object of type DeviceManagerClient. To do so, construct an object of type DeviceManagerClient with an instance of this class. Then use the Google Test framework functions to program the behavior of this mock.
See Also
This example for how to test your application with GoogleTest. While the example showcases types from the BigQuery library, the underlying principles apply for any pair of *Client and *Connection.
Functions
virtual options()
This function is implemented using gMock's MOCK_METHOD().
Consult the gMock documentation to use this mock in your tests.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThis page documents \u003ccode\u003eMockDeviceManagerConnection\u003c/code\u003e, a class designed to simulate responses from \u003ccode\u003eDeviceManagerClient\u003c/code\u003e for testing purposes.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eMockDeviceManagerConnection\u003c/code\u003e utilizes gMock's \u003ccode\u003eMOCK_METHOD()\u003c/code\u003e to implement its functions, allowing developers to program mock behaviors, including errors.\u003c/p\u003e\n"],["\u003cp\u003eThe class offers virtual functions for various operations such as creating, getting, updating, deleting, and listing device registries and devices.\u003c/p\u003e\n"],["\u003cp\u003eIt contains additional methods that can modify cloud configurations, modify device states, manage device connections, and handle IAM policies.\u003c/p\u003e\n"],["\u003cp\u003eThe documentation includes links to GoogleTest examples and advises consulting the gMock documentation to fully utilize the mock in tests.\u003c/p\u003e\n"]]],[],null,["# Class MockDeviceManagerConnection (2.12.0)\n\nVersion 2.12.0keyboard_arrow_down\n\n- [2.15.0-rc (latest)](/cpp/docs/reference/iot/latest/classgoogle_1_1cloud_1_1iot__v1__mocks_1_1MockDeviceManagerConnection)\n- [2.14.0](/cpp/docs/reference/iot/2.14.0/classgoogle_1_1cloud_1_1iot__v1__mocks_1_1MockDeviceManagerConnection)\n- [2.13.0](/cpp/docs/reference/iot/2.13.0/classgoogle_1_1cloud_1_1iot__v1__mocks_1_1MockDeviceManagerConnection)\n- [2.12.0](/cpp/docs/reference/iot/2.12.0/classgoogle_1_1cloud_1_1iot__v1__mocks_1_1MockDeviceManagerConnection)\n- [2.11.0](/cpp/docs/reference/iot/2.11.0/classgoogle_1_1cloud_1_1iot__v1__mocks_1_1MockDeviceManagerConnection) \nA class to mock `DeviceManagerConnection`. \nApplication developers may want to test their code with simulated responses, including errors, from an object of type `DeviceManagerClient`. To do so, construct an object of type `DeviceManagerClient` with an instance of this class. Then use the Google Test framework functions to program the behavior of this mock.\n\n###### See Also\n\n[This example](https://cloud.google.com/cpp/docs/reference/bigquery/2.12.0/bigquery-read-mock) for how to test your application with GoogleTest. While the example showcases types from the BigQuery library, the underlying principles apply for any pair of `*Client` and `*Connection`.\n\nFunctions\n---------\n\n### virtual options()\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual CreateDeviceRegistry(google::cloud::iot::v1::CreateDeviceRegistryRequest const \\&)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual GetDeviceRegistry(google::cloud::iot::v1::GetDeviceRegistryRequest const \\&)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual UpdateDeviceRegistry(google::cloud::iot::v1::UpdateDeviceRegistryRequest const \\&)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual DeleteDeviceRegistry(google::cloud::iot::v1::DeleteDeviceRegistryRequest const \\&)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual ListDeviceRegistries(google::cloud::iot::v1::ListDeviceRegistriesRequest)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual CreateDevice(google::cloud::iot::v1::CreateDeviceRequest const \\&)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual GetDevice(google::cloud::iot::v1::GetDeviceRequest const \\&)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual UpdateDevice(google::cloud::iot::v1::UpdateDeviceRequest const \\&)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual DeleteDevice(google::cloud::iot::v1::DeleteDeviceRequest const \\&)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual ListDevices(google::cloud::iot::v1::ListDevicesRequest)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual ModifyCloudToDeviceConfig(google::cloud::iot::v1::ModifyCloudToDeviceConfigRequest const \\&)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual ListDeviceConfigVersions(google::cloud::iot::v1::ListDeviceConfigVersionsRequest const \\&)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual ListDeviceStates(google::cloud::iot::v1::ListDeviceStatesRequest const \\&)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual SetIamPolicy(google::iam::v1::SetIamPolicyRequest const \\&)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual GetIamPolicy(google::iam::v1::GetIamPolicyRequest const \\&)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const \\&)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual SendCommandToDevice(google::cloud::iot::v1::SendCommandToDeviceRequest const \\&)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual BindDeviceToGateway(google::cloud::iot::v1::BindDeviceToGatewayRequest const \\&)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual UnbindDeviceFromGateway(google::cloud::iot::v1::UnbindDeviceFromGatewayRequest const \\&)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests."]]