I'm trying to test the IDialog Flow with a fake Message so:
var toBot = new Message()
{
ConversationId = Guid.NewGuid().ToString(),
Text = "Test",
};
Func<IDialog<T>> MakeRoot = () => testDialog;
toBot.From = new ChannelAccount(Guid.NewGuid().ToString());
toBot.To = new ChannelAccount(Guid.NewGuid().ToString());
When it hits the PromptDialog.Confirm, it throws the "Microsoft.Rest.HttpOperationException in Microsoft.Bot.Builder.dll ("Access Denied")" exception.
If I don't create
toBot.From = new ChannelAccount(Guid.NewGuid().ToString());
it throws System.NullReferenceException for ChannelId.
PromptDialog.Confirm looks like this:
PromptDialog.Confirm(context, AfterErrorConfirmationAsync, Strings.ConfirmError,
Strings.InvalidInput);
How can I work around this issue?
The issue was caused by this:
await context.PostAsync(replyMessage);
PromptDialog.Confirm(context, AfterErrorConfirmationAsync, Strings.ConfirmError,
Strings.InvalidInput);
Having a confirm dialog immediately after posting a message to the user caused the exception and subsequently test failure. It did not throw this exception during run time though.
I resolved the above issue by combining the reply message with the confirmation string as follows:
PromptDialog.Confirm(context, AfterErrorProcessingAsync, replyMessage + "\n\n" + Strings.ConfirmError,
Strings.InvalidInput);
Leaving this question open if someone has a better workaround.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With