public async Task MessageReceivedAsync( IDialogContext context, IAwaitable <IMessageActivity> argument) { var message = await argument; var linksExtractor = new LinksExtractor(message.Text); int linksCount = linksExtractor.GetDetectedLinksCount(); if (linksCount > 1) { await context.PostAsync( "Wow, let's do one link at a time, i'm not so intelligent yet."); } else if (linksCount == 1) { await context.Forward( new ProcessLinkDialog(), ResumeAfterLinkProcessed, message); } else { context.Wait(MessageReceivedAsync); } }
static void Main(string[] args) { Console.WriteLine(DISCLAIMER); string username = ReadInput("PluralSight Username"); string password = ReadInput("Pluralsight Password", hideInput: true); string courseName = ReadInput("Course name"); Course course = null; try { course = new LinksExtractor().GetLinks(username, password, courseName); } catch (Exception e) { Console.WriteLine(e.Message); return; } Downloader downloader = new Downloader(); ProgressBar bar = null; //Display a progress bar when download starts downloader.DownloadBegin += (sender, e) => { bar = new ProgressBar(100, e.Message); }; //Update the bar as download progresses downloader.DownloadProgressChanged += (sender, e) => { bar.SetProgress(e.Percentage); }; downloader.DownloadCourse(course, Environment.CurrentDirectory); }
public void TestCount(string input, int expectedResult) { var extractor = new LinksExtractor(input); int actualResult = extractor.GetDetectedLinksCount(); Assert.Equal(expectedResult, actualResult); }
public async Task MessageReceivedAsync( IDialogContext context, IAwaitable <IMessageActivity> argument) { await context.SayAsync("ok, processing that doc"); IMessageActivity messageActivity = await argument; string message = messageActivity.Text; var extractor = new LinksExtractor(message); List <string> links = extractor.ExtractLinks(); await context.SayAsync($"ok, got {links.Count} links"); link = links.First(); if (links.Count > 1) { throw new InvalidOperationException( "Cannot process several links at the moment."); } PromptDialog.Number(context, ResumeAfterRateIsSet, "How do you rate this article? (1-10)", "Please retry", 3, null, 1, 10); }
public void TestExtraction(string text, string expectedResult) { var extractor = new LinksExtractor(text); List <string> actualResult = extractor.ExtractLinks(); bool contains = actualResult.Contains(expectedResult); Assert.True(contains); }