Skip to content

Should BatchWrite<T> implement an interface? #1565

Closed
@safv12

Description

@safv12

I'm trying to write a unit test to validate the BatchWrite.Execute invocation, but I'm struggling with the mock of the CreateBatchWrite<T> method because I'm not able to instantiate the BatchWrite<T> class.

I'm using Moq to build the mocks, the code looks like:

this.dynamoDbMock
    .Setup(m => m.CreateBatchWrite<SomeType>(It.IsAny<DynamoDBOperationConfig>()))
    .Returns(Mock.Of<BatchWrite<SomeType>>());

But the Returns part is throwing an error because the BatchWrite class does not have a default constructor.

Possible Solution

I think is a good idea to define an interface for the BatchWrite class. In this way, the unit test will be easier to write.

public class BatchWrite<T> : BatchWrite, IBatchWriteOperations

Metadata

Metadata

Assignees

No one assigned

    Labels

    dynamodbfeature-requestA feature should be added or improved.needs-major-versionCan only be considered for the next major releasep1This is a high priority issuequeuedv4

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions