從BotBuilder測試中使用「DialogTestBase」類,這對我有用。
IBotDataBag dataBag;
var container = Build(Options.LastWriteWinsCachingBotDataStore);
var msg = MakeTestMessage();
using (var scope = DialogModule.BeginLifetimeScope(container, msg))
{
var botData = scope.Resolve<IBotData>();
await botData.LoadAsync(default(CancellationToken));
dataBag = scope.Resolve<Func<IBotDataBag>>()();
}
var context = new Mock<IDialogContext>();
context.Setup(c => c.UserData).Returns(() => dataBag);
context.Object.UserData.SetValue(AppConstants.HelpType, helpType);
的可能的複製[如何單元提示測試微軟機器人對話框(http://stackoverflow.com/questions/42925624/how-to-unit-test-a-microsoft-bot-dialog -with-a-prompt) –
我找不到任何測試UserData的設置和測試。我錯過了嗎? – dolbyarun