コード例 #1
0
        public async Task InterceptOnDelete()
        {
            bool adapterCalled = false;

            void ValidateDelete(ConversationReference r)
            {
                adapterCalled = true;
                Assert.True(false); // Should not be called
            }

            var a = new SimpleAdapter(ValidateDelete);
            var c = new TurnContext(a, new Activity());

            bool wasCalled = false;

            c.OnDeleteActivity((context, convRef, next) =>
            {
                Assert.NotNull(convRef); // Null activity passed in
                wasCalled = true;

                // Do Not Call Next
                return(Task.FromResult <ResourceResponse[]>(null));
            });

            await c.DeleteActivityAsync("1234");

            Assert.True(wasCalled);      // Interceptor was called
            Assert.False(adapterCalled); // Adapter was not
        }
コード例 #2
0
        public async Task InterceptAndMutateOnDelete()
        {
            bool adapterCalled = false;

            void ValidateDelete(ConversationReference r)
            {
                Assert.True(r.ActivityId == "mutated");
                adapterCalled = true;
            }

            var a = new SimpleAdapter(ValidateDelete);
            var c = new TurnContext(a, new Activity());

            c.OnDeleteActivity(async(context, convRef, next) =>
            {
                Assert.NotNull(convRef); // Null activity passed in
                Assert.True(convRef.ActivityId == "1234", "Incorrect Activity Id");
                convRef.ActivityId = "mutated";
                await next();
            });

            await c.DeleteActivityAsync("1234");

            Assert.True(adapterCalled); // Adapter was called + valided the change
        }
コード例 #3
0
        public async Task DeleteOneActivityToAdapter()
        {
            bool deleteCalled = false;

            void ValidateDelete(ConversationReference r)
            {
                Assert.NotNull(r);
                Assert.True(r.ActivityId == "12345");
                deleteCalled = true;
            }

            var a = new SimpleAdapter(ValidateDelete);
            var c = new TurnContext(a, TestMessage.Message());
            await c.DeleteActivityAsync("12345");

            Assert.True(deleteCalled);
        }