コード例 #1
0
        public TestFlow GetTestFlow()
        {
            var sp      = Services.BuildServiceProvider();
            var adapter = sp.GetService <TestAdapter>();

            var testFlow = new TestFlow(adapter, async(context, token) =>
            {
                var bot = sp.GetService <IBot>();
                await bot.OnTurnAsync(context, CancellationToken.None);
            });

            return(testFlow);
        }
コード例 #2
0
        public TestFlow GetTestFlow()
        {
            var sp      = Services.BuildServiceProvider();
            var adapter = sp.GetService <TestAdapter>()
                          .Use(new FeedbackMiddleware(sp.GetService <ConversationState>(), sp.GetService <IBotTelemetryClient>()));

            var testFlow = new TestFlow(adapter, async(context, token) =>
            {
                var bot = sp.GetService <IBot>();
                await bot.OnTurnAsync(context, CancellationToken.None);
            });

            return(testFlow);
        }
コード例 #3
0
        public TestFlow GetSkillTestFlow()
        {
            var sp      = Services.BuildServiceProvider();
            var adapter = sp.GetService <TestAdapter>();

            var testFlow = new TestFlow(adapter, async(context, token) =>
            {
                // Set claims in turn state to simulate skill mode
                var claims = new List <Claim>();
                claims.Add(new Claim(AuthenticationConstants.VersionClaim, "1.0"));
                claims.Add(new Claim(AuthenticationConstants.AudienceClaim, Guid.NewGuid().ToString()));
                claims.Add(new Claim(AuthenticationConstants.AppIdClaim, Guid.NewGuid().ToString()));
                context.TurnState.Add("BotIdentity", new ClaimsIdentity(claims));

                var bot = sp.GetService <IBot>();
                await bot.OnTurnAsync(context, CancellationToken.None);
            });

            return(testFlow);
        }
コード例 #4
0
        public TestFlow GetTestFlow(bool includeUserProfile = true)
        {
            var sp      = Services.BuildServiceProvider();
            var adapter = sp.GetService <TestAdapter>();

            var userState        = sp.GetService <UserState>();
            var userProfileState = userState.CreateProperty <UserProfileState>(nameof(UserProfileState));

            var testFlow = new TestFlow(adapter, async(context, token) =>
            {
                if (includeUserProfile)
                {
                    await userProfileState.SetAsync(context, TestUserProfileState);
                    await userState.SaveChangesAsync(context);
                }

                var bot = sp.GetService <IBot>();
                await bot.OnTurnAsync(context, CancellationToken.None);
            });

            return(testFlow);
        }