更新时间:2023-02-20 20:56:09
使用了BotBuilder测试中的"DialogTestBase"类,它对我有用.
Used the "DialogTestBase" class from BotBuilder tests and this worked for me.
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);