public async Task Waterfall() { var activities = TranscriptUtilities.GetFromTestContext(TestContext); var convState = new ConversationState(new MemoryStorage()); var testProperty = convState.CreateProperty <Dictionary <string, object> >("test"); var adapter = new TestAdapter() .Use(convState); await new TestFlow(adapter, async(turnContext, cancellationToken) => { if (turnContext.Activity.Type == ActivityTypes.Message) { var state = await testProperty.GetAsync(turnContext, () => new Dictionary <string, object>()); var waterfall = new Waterfall(new WaterfallStep[] { async(dc, args, next) => { await dc.Context.SendActivityAsync("step1"); }, async(dc, args, next) => { await dc.Context.SendActivityAsync("step2"); }, async(dc, args, next) => { await dc.Context.SendActivityAsync("step3"); }, }); var dialogCompletion = await waterfall.ContinueAsync(turnContext, state); if (!dialogCompletion.IsActive && !dialogCompletion.IsCompleted) { await waterfall.BeginAsync(turnContext, state); } } }) .Test(activities) .StartTestAsync(); }
public async Task Waterfall() { ConversationState convoState = new ConversationState(new MemoryStorage()); var testProperty = convoState.CreateProperty <Dictionary <string, object> >("test", () => new Dictionary <string, object>()); TestAdapter adapter = new TestAdapter() .Use(convoState); await new TestFlow(adapter, async(turnContext) => { var state = await testProperty.GetAsync(turnContext); var waterfall = new Waterfall(new WaterfallStep[] { async(dc, args, next) => { await dc.Context.SendActivityAsync("step1"); }, async(dc, args, next) => { await dc.Context.SendActivityAsync("step2"); }, async(dc, args, next) => { await dc.Context.SendActivityAsync("step3"); }, }); var dialogCompletion = await waterfall.ContinueAsync(turnContext, state); if (!dialogCompletion.IsActive && !dialogCompletion.IsCompleted) { await waterfall.BeginAsync(turnContext, state); } }) .Send("hello") .AssertReply("step1") .Send("hello") .AssertReply("step2") .Send("hello") .AssertReply("step3") .StartTestAsync(); }