Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need IBatchGet<T> interface for testing #1857

Closed
SARAVANA1501 opened this issue May 20, 2021 · 8 comments
Closed

Need IBatchGet<T> interface for testing #1857

SARAVANA1501 opened this issue May 20, 2021 · 8 comments
Labels
dynamodb feature-request A feature should be added or improved. p1 This is a high priority issue queued

Comments

@SARAVANA1501
Copy link

I would like to have following mocking, Since BatchGet<T> is concrete class, we are unable to mock and test the functionality.

var dynamoDbContext = new Mock<IDynamoDBContext>();
            dynamoDbContext.Setup(t => t.CreateBatchGet<TestModel>(It.IsAny<DynamoDBOperationConfig>()))
                .Returns(new Mock<BatchGet<TestModel>>().Object);
            var service = new TestService(dynamoDbContext.Object);
@SARAVANA1501 SARAVANA1501 added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels May 20, 2021
@SARAVANA1501
Copy link
Author

@ashishdhingra any update on this?

@ashishdhingra
Copy link
Contributor

Hi @SARAVANA1501,

Good afternoon.

BatchGet inherits from the abstract BatchGet class. So you should be able to mock BatchGet. Kindly refer article How to Unit Test an Abstract Class for details. Hope this helps.

Thanks,
Ashish

@ashishdhingra ashishdhingra added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels May 25, 2021
@Kralizek
Copy link
Contributor

@ashishdhingra I wonder if your comment is really relevant. Because the IDynamoDBContext returns BatchGet<T> so if we were to use create a mock from BatchGet, it would be a sibling class of BatchGet<T> making it not usable for what @SARAVANA1501 is trying to achieve.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label May 28, 2021
@github-actions
Copy link

We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label May 28, 2022
@SARAVANA1501
Copy link
Author

Commenting to keeps it open

@github-actions github-actions bot removed the closing-soon This issue will automatically close in 4 days unless further comments are made. label May 29, 2022
@ik130 ik130 added cross-sdk p1 This is a high priority issue and removed cross-sdk labels Dec 1, 2022
@SARAVANA1501
Copy link
Author

@ashishdhingra I would like to contribute on this

SARAVANA1501 pushed a commit to SARAVANA1501/aws-sdk-net that referenced this issue Feb 27, 2023
@96malhar
Copy link
Contributor

96malhar commented Sep 3, 2024

Hello, we have been working on the V4 of the AWS SDK for .NET. We have added the ability to mock various DynamoDB operations by adding interfaces in both the Data Model mode and Document Model mode in DynamoDB.

Refer to this PR - #3450

Specifically for the BatchGet<T> class, it now implements the IBatchGet<T> interface which can be mocked inside unit tests.

This feature is available in the AWSSDK.DynamoDBv2 Version 4.0.0-preview.2

@96malhar 96malhar closed this as completed Sep 3, 2024
Copy link

github-actions bot commented Sep 3, 2024

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dynamodb feature-request A feature should be added or improved. p1 This is a high priority issue queued
Projects
None yet
Development

No branches or pull requests

5 participants