public async Task ThrowExceptionInOnSend() { var a = new SimpleAdapter(); var c = new TurnContext(a, new Activity()); c.OnSendActivities((context, activities, next) => { throw new Exception("test"); }); try { await c.SendActivity(TestMessage.Message()); Assert.Fail("Should not get here"); } catch (Exception ex) { Assert.IsTrue(ex.Message == "test"); } }
public async Task GetLocaleFromActivity() { void ValidateResponses(Activity[] activities) { // no need to do anything. } var a = new SimpleAdapter(ValidateResponses); var c = new TurnContext(a, new Activity()); var activityId = Guid.NewGuid().ToString(); var activity = TestMessage.Message(); activity.Id = activityId; activity.Locale = "de-DE"; Task SimpleCallback(ITurnContext turnContext, CancellationToken cancellationToken) { Assert.Equal("de-DE", ((TurnContext)turnContext).Locale); return(Task.CompletedTask); } await a.ProcessRequest(activity, SimpleCallback, default(CancellationToken)); }
public void AdapterUseChaining() { var a = new SimpleAdapter(); a.Use(new CallCountingMiddleware()).Use(new CallCountingMiddleware()); }
public void AdapterSingleUse() { var a = new SimpleAdapter(); a.Use(new CallCountingMiddleware()); }