I am writing c++ code to talk to azure blob service. I create azure::storage::cloud_blob_container and azure::storage::cloud_block_blob objects, and I use many of the APIs defined for these objects (get_block_blob_reference, delete_blob, upload_text, etc). Since the functions/constructors are not virtualized, I am having trouble defining mock objects and mocking the calls (note that I am using the gtest/gmock framework to unit test).
A workaround that I found online was to templatize the code, and define mock_cloud_blob_container objects, etc and implement all the calls in the mock object. Though this is a bit painful, this is the only solution that I know of to deal with this case.
Is there some easier method to mock the SDK objects, or is the method I am following the only way?
I am writing c++ code to talk to azure blob service. I create
azure::storage::cloud_blob_container
andazure::storage::cloud_block_blob
objects, and I use many of the APIs defined for these objects (get_block_blob_reference
,delete_blob
,upload_text
, etc). Since the functions/constructors are not virtualized, I am having trouble defining mock objects and mocking the calls (note that I am using the gtest/gmock framework to unit test).A workaround that I found online was to templatize the code, and define
mock_cloud_blob_container
objects, etc and implement all the calls in the mock object. Though this is a bit painful, this is the only solution that I know of to deal with this case.Is there some easier method to mock the SDK objects, or is the method I am following the only way?
Thanks!