[英]How to mock user state in bot 4 unit test?
我正在使用用戶配置文件將用戶數據從單元測試項目發送到機器人對話框。 但是我在對話框中得到了空的用戶配置文件。
測試項目:
var conversationStateAccessors = _ConversationState.CreateProperty<UserProfile>(nameof(UserProfile));
var conversationData = await conversationStateAccessors.GetAsync(turn, () => new UserProfile());
conversationData.UserEmailId = "vikash.ranjan.jha";
conversationData.UserName = "vikash";
await _ConversationState.SaveChangesAsync(turn, false, It.IsAny<CancellationToken>());
機器人對話框:
_userProfileAccessor = conversationState.CreateProperty<UserProfile>(nameof(UserProfile));
var userProfile = await _userProfileAccessor.GetAsync(stepContext.Context, () => new UserProfile(), cancellationToken);
此用戶配置文件為空。
使用 Azure Blob 存儲而不是本地內存存儲
services.AddSingleton<IStorage, MemoryStorage>();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.