【发布时间】:2021-03-31 14:58:09
【问题描述】:
我正在尝试为以下代码编写单元测试:
这是我的逻辑
public async Task RemoveUser(string id)
{
var response = await _graphQLClient.SendMutationAsync<Response>(request);
if (response.Errors != null)
{
throw new ClientException(errorMessages);
}
}
这是我的单元测试
[Test]
public void RemoveUser_ShouldCancelUserOnSucessfulRemoval()
{
_mockGraphQLClient
.Setup(client => client.SendMutationAsync<object>(It.IsAny<GraphQLRequest>(), It.Is<CancellationToken>(token => token == default)))
.ReturnsAsync( new GraphQLResponse<object>());
var psClient = new PsClient(_mockGraphQLClient.Object);
var removeUserResults = psClient.RemoveUser(id);
Assert.AreEqual(removeUserResults, /* what to put here? */ );
}
我不知道应该比较我的结果吗?
以及如何处理:
?
【问题讨论】:
-
费德里克;为什么你删除了大部分问题?就像现在一样,质量非常低,不太可能帮助别人。最初提供的代码为其他人提供了更多与他们自己的问题相关的上下文。
-
我恢复了您的编辑,以挽救问题并保持其质量。
标签: c# unit-testing asp.net-core async-await graphql