5

I’m trying to write a unit test in c# and I need to mock the response of the method CreateBatchWrite<T> using Moq but I can’t instantiate an object of the BatchWrite<T> object. I’m doing this:

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

Any idea of how can I mock this object. Thank you!

safv12
  • 51
  • 4

1 Answers1

0

I also got struck with this. From other post i come to know that since BatchWrite is concrete class and also all its public methods are not decorated with virtual keyword. It made them not to be mocked.

Refer here: Moq - Non-overridable members may not be used in setup / verification expressions