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 details the \u003ccode\u003eMockDeviceManagerConnection\u003c/code\u003e class, which is designed to simulate responses, including errors, for testing application code that uses \u003ccode\u003eDeviceManagerClient\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eMockDeviceManagerConnection\u003c/code\u003e class utilizes the gMock framework's \u003ccode\u003eMOCK_METHOD()\u003c/code\u003e for all of its virtual functions, enabling flexible mocking in tests.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can use an instance of the \u003ccode\u003eMockDeviceManagerConnection\u003c/code\u003e class with a \u003ccode\u003eDeviceManagerClient\u003c/code\u003e to programmatically control the behavior of the mock during testing.\u003c/p\u003e\n"],["\u003cp\u003eThe documentation provides examples and links to gMock and GoogleTest resources to facilitate implementation of the mock within the application tests.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eMockDeviceManagerConnection\u003c/code\u003e class includes virtual functions to mock all key actions of the \u003ccode\u003eDeviceManagerConnection\u003c/code\u003e class, like creating, getting, updating, deleting, and listing device registries and devices.\u003c/p\u003e\n"]]],[],null,["# Class MockDeviceManagerConnection (2.11.0)\n\nVersion 2.11.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://googleapis.dev/cpp/google-cloud-bigquery/2.11.0/bigquery-read-mock.html) 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."]]