Closed
Description
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