private async Task <DialogTurnResult> GetComputerRecommendations(WaterfallStepContext stepContext, CancellationToken cancellationToken) { await stepContext.Context.SendActivityAsync( BotStrings.We_taking_personal_info_retrieve_recommendations, cancellationToken : cancellationToken); var person = _accessors.GetPersonAsync(stepContext.Context, cancellationToken); if (_recommender.IsReadyToGiveRecommendation()) { _recommender.GetNewComputerRecommendations(await person) .AsParallel() .ForAll(async r => await stepContext.Context.SendActivityAsync(r.RecommendMessage(), cancellationToken: cancellationToken)); } else { await stepContext.Context.SendActivityAsync(BotStrings.No_Recommendation_engine, cancellationToken : cancellationToken); } return(await stepContext.NextAsync(cancellationToken : cancellationToken)); }
public async Task FullConversation_NewComputerRecommendation() { var recommendations = new[] { "DDR: 3", "Processor: 4" }; var recommendFake = A.Fake <IRecommend>(); A.CallTo(() => recommendFake.RecommendMessage()).ReturnsNextFromSequence(recommendations); A.CallTo(() => _recommender.IsReadyToGiveRecommendation()).Returns(true); A.CallTo(() => _recommender.GetNewComputerRecommendations(A <Person> .Ignored)) .Returns(Enumerable.Repeat(recommendFake, recommendations.Length)); await new TestFlow(_adapter, _bot) .Send("Hi") .AssertReplyContain(BotStrings.MainMenuTitle, "Main menu") .Send("NewComputerDialogComponent") // TODO: Bug, duplicate message .AssertReplyContain(BotStrings.We_need_some_information, "The user not exist") .AssertNewUserInsertData() .AssertReplyContain(BotStrings.We_taking_personal_info_retrieve_recommendations) .AssertEachReplyContainOneOf(recommendations) .StartTestAsync(); }