相关疑难解决方法(0)

C# 模拟单元测试 GraphServiceClient

我在使用 Moq 和 xUnit 在 C# 中编写单元测试时遇到问题。

在我的服务中,我有以下代码:

var options = new TokenCredentialOptions
{
    AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
};

var clientSecretCredential = new ClientSecretCredential(tenantId, clientId, clientSecret, options);
var graphClient = new GraphServiceClient(clientSecretCredential);


return (await graphClient.Users.Request().Filter($"displayName eq '{mobilePhone}'").GetAsync()).FirstOrDefault();

Run Code Online (Sandbox Code Playgroud)

但我不知道模拟该函数的方法GraphClient

graphClient.Users.Request().Filter($"displayName eq '{mobilePhone}'").GetAsync()).FirstOrDefault();
Run Code Online (Sandbox Code Playgroud)

c# moq xunit azure

7
推荐指数
1
解决办法
6853
查看次数

标签 统计

azure ×1

c# ×1

moq ×1

xunit ×1