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

Ability to mock generic TransactWrite<T> #2630

Closed
1 task done
roelvandenbrand opened this issue Jun 13, 2023 · 5 comments
Closed
1 task done

Ability to mock generic TransactWrite<T> #2630

roelvandenbrand opened this issue Jun 13, 2023 · 5 comments
Labels
dynamodb feature-request A feature should be added or improved. needs-major-version Can only be considered for the next major release p1 This is a high priority issue queued v4

Comments

@roelvandenbrand
Copy link

roelvandenbrand commented Jun 13, 2023

Describe the feature

With a IAmazonDynamoDB or IDynamoDBContext I would like to be able to return TransactWrite. There does not seem to be a public constructor or interface which would be very handy.

Use Case

Mocking Transactions. First building the TransactWriteItems with AddSaveItem and such. And at last do a mocked ExecuteAsync call.

Proposed Solution

Make a public constructor for TransactWrite or an interface to be able to mock it directly.

Other Information

I also tried the DbContext.CreateTransactWrite with a mocked DescribeTablesAsync, but internally DescribeTables is used. Which is not in the interface. So I could not create a TransactWrite that way either.

Acknowledgements

  • I may be able to implement this feature request

AWS .NET SDK and/or Package version used

AWSSDK.DynamoDBv2 3.7.103.20

Targeted .NET Platform

.NET 6

Operating System and version

Windows 11, AmazonLinux

@roelvandenbrand roelvandenbrand added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jun 13, 2023
@ashishdhingra ashishdhingra added dynamodb needs-review and removed needs-triage This issue or PR still needs to be triaged. labels Jun 13, 2023
@ashishdhingra
Copy link
Contributor

Needs review with the team. Similar feature requests to improve testability are queued.

@roelvandenbrand
Copy link
Author

roelvandenbrand commented Jun 14, 2023

@ashishdhingra

I can try to add in the interfaces in a PR specifically for this.

@ashishdhingra ashishdhingra added p1 This is a high priority issue needs-major-version Can only be considered for the next major release queued and removed needs-review labels Jun 23, 2023
@roelvandenbrand
Copy link
Author

Needs review with the team. Similar feature requests to improve testability are queued.

I see there are a few, but priority might be at other issues. It looks like changing stuff to return interfaces would break some implementations. But it will improve testability for a lot of people. Is there anything I could help with?

@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 TransactWrite<T> class, it now implements the ITransactWrite<T> interface which can 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. needs-major-version Can only be considered for the next major release p1 This is a high priority issue queued v4
Projects
None yet
Development

No branches or pull requests

3 participants