How can we ridicule AWS services

Aws-sdk-net: DynamoDBContext.CreateBatchGet cannot be mocked due to missing interfaces


When I try to unit test code that uses DynamoDBContext.CreateBatchGet, I can't get incorrect results. The BatchGet

Expected behavior



The easiest way would be to add IBatchGet

Current behavior






BatchGet

After doing that, I like weird exceptions to SDK internals

and still I don't see an easy way to return results :(

I could make some changes to my code by adding some unwanted entity attributes and be able to solve this problem, but then I'm at the execution of the batch and there is still no easy way to provide the results. I could:

In this case, however, I can't find an easy way to provide fake data via the mocked IDynamoDBContext or the mocked IAmazonDynamoDB.

I also can't return bogus data using any other approach

Since in this case the public ExecuteBatchGetAsync method is not marked as virtual, it is difficult to make this call with e.g. NSubstitutes.

Possible solution



Add the IBatchGet interface for CreateBatchGet in IDynamoDBContext.
(or) Make ExecuteBatchGetAsync virtual in DynamoDBContext

I can make a pull request for this change if you feel you need one :)

Steps to reproduce (for errors)





Write a unit test that returns fake data from the batch API.

Your environment

  • AWSSDK.DynamoDBv2 (3.3.101.59)
breaking-changebugmoduldynamodb