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");
            }
        }
示例#2
0
        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));
        }
示例#3
0
        public void AdapterUseChaining()
        {
            var a = new SimpleAdapter();

            a.Use(new CallCountingMiddleware()).Use(new CallCountingMiddleware());
        }
示例#4
0
        public void AdapterSingleUse()
        {
            var a = new SimpleAdapter();

            a.Use(new CallCountingMiddleware());
        }