gpt4 book ai didi

azure - 模拟 TableClient DeleteEntityAsync - Azure.Response

转载 作者:行者123 更新时间:2023-12-02 08:17:08 30 4
gpt4 key购买 nike

我需要模拟 TableClientDeleteEntityAsync 方法。
TableClient.DeleteEntityAsync

我当前的实现使用响应对象。

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));

如何在模拟中设置 ContentStatusCode?目前尚未分配任何值。

enter image description here

最佳答案

我正在做同样的事情。试试这个:

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);

关于azure - 模拟 TableClient DeleteEntityAsync - Azure.Response,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72565342/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com