Reputation: 3937
I need to mock the DeleteEntityAsync
method of TableClient
.
TableClient.DeleteEntityAsync
My current implementation uses an empty Response object.
var mockResponse = new Mock<Azure.Response>();
Mock<TableClient> tableClient = new Mock<TableClient>();
tableClient.Setup(_ => _.DeleteEntityAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<Azure.ETag>(), It.IsAny<System.Threading.CancellationToken>()))
.Returns(Task.FromResult(mockResponse.Object));
How can I set Content
and StatusCode
in the mock? At the moment no values are assigned.
Upvotes: 2
Views: 5057
Reputation: 4618
I'm working on the same thing. Try this:
var mockResponse = new Mock<Response>();
mockResponse.SetupGet(x => x.Status).Returns((int)HttpStatusCode.NotFound);
mockResponse.SetupGet(x => x.Content).Returns(BinaryData.FromString("data source here"));
tableClient.Setup(x => x.DeleteEntityAsync(It.IsAny<string>(), It.IsAny<string>(), default, default)).ReturnsAsync(mockResponse.Object);
Upvotes: 4