带有 TestFlow 和 Adapter 的 Enterprise Bot Template 上提供了一些测试工具。
我们能否使用 TestFlow 提交测试数据,就好像它已在自适应卡中填充并提交回机器人以测试来自 TestMethod 的响应?不是文本,而是填写好的回复。
方法如下,注释放在适当的操作位置。
[TestMethod]
public async Task TestSoftwareIssue()
{
string response = "What sort of issue do you have?\n\n" +
" 1. Computer\n" +
" 2. Software\n" +
" 3. Insuffient Permissions for Access\n" +
" 4. Account expired\n" +
" 5. Other";
await GetTestFlow()
.Send(GeneralUtterances.GeneralIssue)
.AssertReply(response)
.Send("software")
// .AssertReply("")
.AssertReply(activity => CheckAttachment(activity.AsMessageActivity()))
// How to send a Adaptive Card filled out message back?
.StartTestAsync();
}
这里还有自适应卡片的简化版本。
{
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"text": "Email"
},
{
"type": "Input.Text",
"id": "Email",
"placeholder": "name@example.com"
},
{
"type": "TextBlock",
"text": "Summary"
},
{
"type": "Input.Text",
"id": "Summary",
"placeholder": "Please describe the issue",
"isMultiline": true
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Submit",
"data": {
"form": "Ticket"
}
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0"
}
最佳答案
只是一个更新。 我已经成功地实现了这样的工作。
这是一个示例测试,其中 responseOne 是一个 json 格式的字符串,它保存 accessForm.json 中数据字段的键值对
[TestMethod]
public async Task TestFormProcess()
// ...
await GetTestFlow()
.Send(GeneralUtterances.Access)
.AssertReply(activity => CheckAttachment(activity.AsMessageActivity(), @".\Resources\TestForms\accessForm.json"))
.Send(CreateReply(responseOne))
.AssertReply("Some reply")
.StartTestAsync();
public IActivity CreateReply(string json)
{
return new Activity()
{
Value = JsonConvert.DeserializeObject(file),
};
}
关于c# - 如何将Adaptive Card填写的数据传回TestFlow和TestAdapter进行测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55945561/