我必须为BotFramework V4简单的echo方法编写单元测试用例,但是我找不到模拟机器人的方法。其实我不知道从哪里开始。我已经阅读了所有可以在Google上找到的与之相关的文档,但是都没有在代码级别上进行说明。一个具体的例子将有很大帮助。
[TestMethod]
public async Task CreatingAGoodContact()
{
var convoState = new ConversationState(new MemoryStorage());
var adapter = new TestAdapter()
.Use(new AutoSaveStateMiddleware(convoState));
var dialogState = convoState.CreateProperty<DialogState>
("dialogState");
var dialogs = new DialogSet(dialogState);
dialogs.Add(CreateWaterfall());
await new TestFlow(adapter, async (turnContext,
cancellationToken) =>
{
var dc = await dialogs.CreateContextAsync(turnContext,
cancellationToken);
// await dc.ContinueDialogAsync(cancellationToken);
if (!turnContext.Responded)
{
await dc.BeginDialogAsync("test-waterfall", null,
cancellationToken);
}
})
.Send("Say something to start test")
.AssertReply("What is their first name?")
}
答案 0 :(得分:0)
您需要调用.StartTestAsync()才能开始执行测试