C# 如何在BOT4单元测试中模拟用户状态?

C# 如何在BOT4单元测试中模拟用户状态?,c#,botframework,C#,Botframework,我正在使用用户配置文件将用户数据从单元测试项目发送到bot对话框。 但我在对话框中得到了空的用户配置文件 测试项目: var conversationStateAccessors = _ConversationState.CreateProperty<UserProfile>(nameof(UserProfile)); var conversationData = await conversationStateAccessors.GetAsync(tu

我正在使用用户配置文件将用户数据从单元测试项目发送到bot对话框。 但我在对话框中得到了空的用户配置文件

测试项目:

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>());
var conversationStateAccessors=\u ConversationState.CreateProperty(nameof(UserProfile));
var conversationData=await conversationStateAccessors.GetAsync(turn,()=>newuserprofile());
conversationData.UserEmailId=“vikash.ranjan.jha”;
conversationData.UserName=“vikash”;
wait_ConversationState.saveChangesSync(turn,false,It.IsAny());
机器人程序对话框:

_userProfileAccessor = conversationState.CreateProperty<UserProfile>(nameof(UserProfile));

var userProfile = await _userProfileAccessor.GetAsync(stepContext.Context, () => new UserProfile(), cancellationToken);
\u userProfileAccessor=conversationState.CreateProperty(nameof(UserProfile));
var userProfile=await _userProfileAccessor.GetAsync(stepContext.Context,()=>newuserprofile(),cancellationToken);

此用户配置文件为空。

用户Azure Blob存储,而不是本地内存存储

services.AddSingleton<IStorage, MemoryStorage>();
services.AddSingleton();

使用Azure Blob存储代替本地内存存储

services.AddSingleton<IStorage, MemoryStorage>();
services.AddSingleton();