Using a mocked IAmazonDynamoDB instance in DynamoDBContext #1801
Labels
closed-for-staleness
dynamodb
guidance
Question that needs advice or information.
response-requested
Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
The Question
Is there any way to inject a mocked
IAmazonDynamoDB
instance intoAmazonDynamoDB
, in order to catch the request that hits the mocked client so the request details can be verified?I'm trying to do so by injecting a mocked
IAmazonDynamoDB
instance intoDynamoDBContext
, constructing a new instance of my class to be passed into the DynamoDBContext, and calling SaveAsync, but I'm hitting aNullReferenceException
.The exception I'm hitting is:
This seems to be a result of the SDK casting the injected
IAmazonDynamoDB
instance toAmazonDynamoDBClient
when usingNETSTANDARD
. TheAmazon.DynamoDBv2.DocumentModel.Table
class's private constructor casts the mocked interface toAmazonDynamoDBClient
, but the cast fails and results innull
. This is the code which seems to be causing the null.Perhaps I'm using the wrong approach to achieve my goal. If there's any way to do this, I'd appreciate the support. Thanks!
Environment
This is a ❓ general question
The text was updated successfully, but these errors were encountered: