C# 我们可以使用TestAdaptor和TestFlow对自适应卡回复进行测试吗?僵尸框架

C# 我们可以使用TestAdaptor和TestFlow对自适应卡回复进行测试吗?僵尸框架,c#,unit-testing,botframework,integration-testing,C#,Unit Testing,Botframework,Integration Testing,已经在bot的企业模板4.2.2中编写了一些测试,到目前为止,它对于基于文本的响应非常有效。但是,当流程涉及自适应卡时,是否有方法访问附件以确保一切按预期工作 在该对话框中,当选择软件时,将发送回自适应卡。 从客户端看是这样的。 任何关于如何验证自适应卡输出的建议都将非常有用 我认为需要有某种方式来访问发送给用户的bot的活动附件,但现在确定如何完成这项工作时遇到了一些困难 谢谢 因此,经过一些探索,找到了一种方法来解决这个问题,这个函数是TestFlow的一部分 /// <param

已经在bot的企业模板4.2.2中编写了一些测试,到目前为止,它对于基于文本的响应非常有效。但是,当流程涉及自适应卡时,是否有方法访问附件以确保一切按预期工作

在该对话框中,当选择软件时,将发送回自适应卡。 从客户端看是这样的。

任何关于如何验证自适应卡输出的建议都将非常有用

我认为需要有某种方式来访问发送给用户的bot的活动附件,但现在确定如何完成这项工作时遇到了一些困难


谢谢

因此,经过一些探索,找到了一种方法来解决这个问题,这个函数是TestFlow的一部分


/// <param name="validateActivity">A validation method to apply to an activity from the bot.
/// This activity should throw an exception if validation fails.</param>

public TestFlow AssertReply(Action<IActivity> validateActivity, [CallerMemberName] string description = null, uint timeout = 3000)

[TestMethod]可以像这样工作

[TestMethod]
public async Task TestSoftwareIssue()
{
    await GetTestFlow()
        .Send(GeneralUtterances.GeneralIssue)
        .AssertReply("Some Response")
        .Send("Some Choice")
        // .AssertReply("")
        .AssertReply(activity => CheckAttachment(activity.AsMessageActivity()))
        .StartTestAsync();
}

是否有原因
CheckAttachment
的返回类型不是
void
?不是真的,将帖子更新为返回类型void。谢谢
public void CheckAttachment(IMessageActivity messageActivity)
{
    // Check if content is the same
    var messageAttachment = messageActivity.Attachments.First();
    // Example attachment
    var adaptiveCardJson = File.ReadAllText(@".\Resources\TicketForm.json");

    var expected = new Attachment()
    {
        ContentType = "application/vnd.microsoft.card.adaptive",
        Content = JsonConvert.DeserializeObject(adaptiveCardJson),
    };

    Assert.AreEqual(messageAttachment.Content.ToString(), expected.Content.ToString());
}
[TestMethod]
public async Task TestSoftwareIssue()
{
    await GetTestFlow()
        .Send(GeneralUtterances.GeneralIssue)
        .AssertReply("Some Response")
        .Send("Some Choice")
        // .AssertReply("")
        .AssertReply(activity => CheckAttachment(activity.AsMessageActivity()))
        .StartTestAsync();
}