以下函数的返回值为 (bool, string) .如何对其进行Moq,以便为单元测试做好准备。
(bool, string)
Task<(bool, string)> CreatePhoneCertificate( int orderId, CancellationToken cancellationToken);
var mockInsuranceService = new Mock<IInsuranceService>(); mockInsuranceService .Setup(x => x.CreatePhoneCertificate(12345, It.IsAny<CancellationToken>())) .ReturnsAsync(???);
非常感谢。
只需创建一个具有所需值的值元组:
mockInsuranceService.Setup(x => x.CreatePhoneCertificate(12345, It.IsAny<CancellationToken>())) .ReturnsAsync((true, "someString"));
阅读更多: