public void NumberPromptWithNullIdShouldFail() { var nullId = ""; nullId = null; var numberPrompt = new NumberWithUnitPrompt(nullId, NumberWithUnitPromptType.Currency); }
public async Task NumberWithUnitPrompt_Type_Currency() { var convoState = new ConversationState(new MemoryStorage()); var dialogState = convoState.CreateProperty <DialogState>("dialogState"); var adapter = new TestAdapter() .Use(new AutoSaveStateMiddleware(convoState)); // Create new DialogSet. var dialogs = new DialogSet(dialogState); // Create and add number prompt to DialogSet. var numberPrompt = new NumberWithUnitPrompt("CurrencyPrompt", NumberWithUnitPromptType.Currency, defaultLocale: Culture.English); dialogs.Add(numberPrompt); await new TestFlow(adapter, async(turnContext, cancellationToken) => { var dc = await dialogs.CreateContextAsync(turnContext, cancellationToken); var results = await dc.ContinueDialogAsync(cancellationToken); if (!turnContext.Responded && results.Status == DialogTurnStatus.Empty && results.Status != DialogTurnStatus.Complete) { var options = new PromptOptions { Prompt = new Activity { Type = ActivityTypes.Message, Text = "Enter a currency." } }; await dc.PromptAsync("CurrencyPrompt", options, cancellationToken); } else if (results.Status == DialogTurnStatus.Complete) { var currencyPromptResult = (NumberWithUnitResult)results.Result; if (currencyPromptResult != null) { await turnContext.SendActivityAsync(MessageFactory.Text($"Bot received Value: {currencyPromptResult.Value}, Unit: {currencyPromptResult.Unit}"), cancellationToken); } else { await turnContext.SendActivityAsync(MessageFactory.Text($"Nothing recognized"), cancellationToken); } } }) .Send("hello") .AssertReply("Enter a currency.") .Send("42 dollars") .AssertReply("Bot received Value: 42, Unit: Dollar") .Send("hello") .AssertReply("Enter a currency.") .Send("twenty five dollars") .AssertReply("Bot received Value: 25, Unit: Dollar") .Send("hello") .AssertReply("Enter a currency.") .Send("£50.5") .AssertReply("Bot received Value: 50.5, Unit: Pound") .StartTestAsync(); }
public void NumberPromptWithEmptyIdShouldFail() { var emptyId = ""; var numberPrompt = new NumberWithUnitPrompt(emptyId, NumberWithUnitPromptType.Currency); }