示例#1
0
        public async Task LocaleConvertToEnglish()
        {
            var botLocale = "en-us";

            var activities = TranscriptUtilities.GetFromTestContext(TestContext);

            var userState    = new UserState(new MemoryStorage());
            var userLangProp = userState.CreateProperty <string>("language", () => "en-us");

            TestAdapter adapter = new TestAdapter()
                                  .Use(userState)
                                  .Use(new LocaleConverterMiddleware(userLangProp, botLocale, LocaleConverter.Converter));

            var flow = new TestFlow(adapter, async(context, cancellationToken) =>
            {
                if (context.Activity.Type == ActivityTypes.Message)
                {
                    var userMessage = context.Activity.Text.ToLowerInvariant();
                    if (userMessage.StartsWith("set language "))
                    {
                        await userLangProp.SetAsync(context, userMessage.Substring(13, 5));
                    }
                    else
                    {
                        await context.SendActivityAsync($"message: {context.Activity.Text}");
                    }
                }
            });

            await flow.Test(activities, (expected, actual) =>
            {
                Assert.AreEqual(expected.AsMessageActivity().Text, actual.AsMessageActivity().Text);
            }).StartTestAsync();
        }
        private static TestFlow BuildTestFlow(Dialog targetDialog)
        {
            var convoState  = new ConversationState(new MemoryStorage());
            var testAdapter = new TestAdapter()
                              .Use(new AutoSaveStateMiddleware(convoState));
            var dialogState = convoState.CreateProperty <DialogState>("DialogState");
            var testFlow    = new TestFlow(testAdapter, async(turnContext, cancellationToken) =>
            {
                var state   = await dialogState.GetAsync(turnContext, () => new DialogState(), cancellationToken);
                var dialogs = new DialogSet(dialogState);

                dialogs.Add(targetDialog);

                var dc = await dialogs.CreateContextAsync(turnContext, cancellationToken);

                var results = await dc.ContinueDialogAsync(cancellationToken);
                switch (results.Status)
                {
                case DialogTurnStatus.Empty:
                    await dc.BeginDialogAsync(targetDialog.Id, null, cancellationToken);
                    break;

                case DialogTurnStatus.Complete:
                    {
                        // TODO: Dialog has ended, figure out a way of asserting that this is the case.
                        break;
                    }
                }
            });

            return(testFlow);
        }
示例#3
0
        public async Task SkillMiddlewarePopulatesSkillContextDifferentDatatypes()
        {
            string jsonSkillBeginActivity = await File.ReadAllTextAsync(@".\TestData\skillBeginEvent.json");

            var skillBeginEvent = JsonConvert.DeserializeObject <Activity>(jsonSkillBeginActivity);

            var skillContextData = new SkillContext();

            skillContextData.Add("PARAM1", DateTime.Now);
            skillContextData.Add("PARAM2", 3);
            skillContextData.Add("PARAM3", null);

            // Ensure we have a copy
            skillBeginEvent.Value = new SkillContext(skillContextData);

            TestAdapter adapter = new TestAdapter()
                                  .Use(new SkillMiddleware(_userState, _conversationState, _dialogStateAccessor));

            var testFlow = new TestFlow(adapter, async(context, cancellationToken) =>
            {
                // Validate that SkillContext has been populated by the SKillMiddleware correctly
                await ValidateSkillContextData(context, skillContextData);
            });

            await testFlow.Test(new Activity[] { skillBeginEvent }).StartTestAsync();
        }
示例#4
0
        public async Task LogsInformationToILogger()
        {
            // Arrange
            var memoryStorage     = new MemoryStorage();
            var conversationState = new ConversationState(memoryStorage);
            var userState         = new UserState(memoryStorage);

            var mockRootDialog = SimpleMockFactory.CreateMockDialog <Dialog>(null, "mockRootDialog");
            var mockLogger     = new Mock <ILogger <DialogBot <Dialog> > >();

            mockLogger.Setup(x =>
                             x.Log(It.IsAny <LogLevel>(), It.IsAny <EventId>(), It.IsAny <object>(), null, It.IsAny <Func <object, Exception, string> >()));

            // Run the bot
            var sut         = new DialogBot <Dialog>(conversationState, userState, mockRootDialog.Object, mockLogger.Object);
            var testAdapter = new TestAdapter();
            var testFlow    = new TestFlow(testAdapter, sut);
            await testFlow.Send("Hi").StartTestAsync();

            // Assert that log was changed with the expected parameters
            mockLogger.Verify(
                x => x.Log(
                    LogLevel.Information,
                    It.IsAny <EventId>(),
                    It.Is <object>(o => o.ToString() == "Running dialog with Message Activity."),
                    null,
                    It.IsAny <Func <object, Exception, string> >()),
                Times.Once);
        }
示例#5
0
        public async Task CustomStateTest()
        {
            var activities = TranscriptUtilities.GetFromTestContext(TestContext);

            var storage = new MemoryStorage();

            TestAdapter adapter = new TestAdapter()
                                  .Use(new CustomState(storage));

            var flow = new TestFlow(adapter, async(context) => {
                var(command, value) = GetCommandValue(context);
                switch (command)
                {
                case "delete":
                    CustomState.Get(context).Value = null;
                    break;

                case "set":
                    CustomState.Get(context).Value = value;
                    break;

                case "read":
                    await context.SendActivityAsync($"value:{CustomState.Get(context).Value}");
                    break;

                default:
                    await context.SendActivityAsync("bot message");
                    break;
                }
            });

            await flow.Test(activities).StartTestAsync();
        }
示例#6
0
        public async Task TranslateToUserLanguage()
        {
            if (!EnvironmentVariablesDefined())
            {
                Assert.Inconclusive("Missing Translator Environment variables - Skipping test");
                return;
            }

            var nativeLanguages = new string[] { };
            var patterns        = new Dictionary <string, List <string> >();

            var activities   = TranscriptUtilities.GetFromTestContext(TestContext);
            var userState    = new UserState(new MemoryStorage());
            var userLangProp = userState.CreateProperty <string>("language");

            TestAdapter adapter = new TestAdapter()
                                  .Use(userState)
                                  .Use(new TranslationMiddleware(nativeLanguages, translatorKey, patterns, new CustomDictionary(), userLangProp, true));

            var flow = new TestFlow(adapter, async(context, cancellationToken) =>
            {
                if (!context.Responded)
                {
                    await context.SendActivityAsync($"message: {context.Activity.Text}");
                }
            });

            await flow.Test(activities).StartTestAsync();
        }
示例#7
0
        public async Task TranslateToEnglish()
        {
            if (!EnvironmentVariablesDefined())
            {
                Assert.Inconclusive("Missing Translator Environment variables - Skipping test");
                return;
            }

            var nativeLanguages = new string[] { "en-us" };
            var patterns        = new Dictionary <string, List <string> >();

            var activities = TranscriptUtilities.GetFromTestContext(TestContext);

            TestAdapter adapter = new TestAdapter()
                                  .Use(new UserState <LanguageState>(new MemoryStorage()))
                                  .Use(new TranslationMiddleware(nativeLanguages, translatorKey, patterns, new CustomDictionary(), GetUserLanguage, SetUserLanguage, false));

            var flow = new TestFlow(adapter, async(context) => {
                if (!context.Responded)
                {
                    await context.SendActivityAsync($"message: {context.Activity.Text}");
                }
            });

            await flow.Test(activities).StartTestAsync();
        }
示例#8
0
        public async Task Test()
        {
            //Assert
            var welcomeBot = new DialogAndWelcomeBot <Dialog>(conversationStateMock.Object, userStateMock.Object,
                                                              dialogMock.Object, loggerMock.Object, decisionMakerMock.Object, threadedLoggerMock.Object);

            var logger = new Mock <ILogger <DialogAndWelcomeBot <Dialog> > >();

            logger.Setup(x =>
                         x.Log(It.IsAny <LogLevel>(), It.IsAny <EventId>(), It.IsAny <object>(), null,
                               It.IsAny <Func <object, Exception, string> >()));

            //Act
            var adapter  = new TestAdapter();
            var testFlow = new TestFlow(adapter, welcomeBot);

            await testFlow.Send("message").StartTestAsync();

            //Assert

            /* logger.Verify(
             *   x => x.Log(
             *       LogLevel.Information,
             *       It.IsAny<EventId>(),
             *       It.Is<object>(o => o.ToString() == ""),
             *       null,
             *       It.IsAny<Func<object, Exception, string>>()),
             *   Times.Once);*/
        }
        protected TestFlow GetSkillTestFlow()
        {
            var sp      = Services.BuildServiceProvider();
            var adapter = sp.GetService <TestAdapter>();

            adapter.AddUserToken(AuthenticationProvider, adapter.Conversation.ChannelId, adapter.Conversation.User.Id, TestToken, MagicCode);

            StartActivity = Activity.CreateConversationUpdateActivity();
            StartActivity.MembersAdded = new ChannelAccount[] { adapter.Conversation.User, adapter.Conversation.Bot };

            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);
        }
        private static TestFlow CreateTestFlow(WaterfallDialog waterfallDialog)
        {
            var convoState  = new ConversationState(new MemoryStorage());
            var dialogState = convoState.CreateProperty <DialogState>("dialogState");

            var adapter = new TestAdapter()
                          .Use(new AutoSaveStateMiddleware(convoState));

            var testFlow = new TestFlow(adapter, async(turnContext, cancellationToken) =>
            {
                var state   = await dialogState.GetAsync(turnContext, () => new DialogState(), cancellationToken);
                var dialogs = new DialogSet(dialogState);

                dialogs.Add(new CancelledComponentDialog(waterfallDialog));

                var dc = await dialogs.CreateContextAsync(turnContext, cancellationToken);

                var results = await dc.ContinueDialogAsync(cancellationToken);
                if (results.Status == DialogTurnStatus.Empty)
                {
                    results = await dc.BeginDialogAsync("TestComponentDialog", null, cancellationToken);
                }
                if (results.Status == DialogTurnStatus.Cancelled)
                {
                    await turnContext.SendActivityAsync(MessageFactory.Text($"Component dialog cancelled (result value is {results.Result?.ToString()})."), cancellationToken);
                }
                else if (results.Status == DialogTurnStatus.Complete)
                {
                    var value = (int)results.Result;
                    await turnContext.SendActivityAsync(MessageFactory.Text($"Bot received the number '{value}'."), cancellationToken);
                }
            });

            return(testFlow);
        }
示例#11
0
        public async Task SavesTurnStateUsingMockWithVirtualSaveChangesAsync()
        {
            // Note: this test requires that SaveChangesAsync is made virtual in order to be able to create a mock.
            var memoryStorage         = new MemoryStorage();
            var mockConversationState = new Mock <ConversationState>(memoryStorage)
            {
                CallBase = true,
            };

            var mockUserState = new Mock <UserState>(memoryStorage)
            {
                CallBase = true,
            };

            var mockRootDialog = SimpleMockFactory.CreateMockDialog <Dialog>(null, "mockRootDialog");
            var mockLogger     = new Mock <ILogger <DialogBot <Dialog> > >();

            // Act
            var sut         = new DialogBot <Dialog>(mockConversationState.Object, mockUserState.Object, mockRootDialog.Object, mockLogger.Object);
            var testAdapter = new TestAdapter();
            var testFlow    = new TestFlow(testAdapter, sut);
            await testFlow.Send("Hi").StartTestAsync();

            // Assert that SaveChangesAsync was called
            mockConversationState.Verify(x => x.SaveChangesAsync(It.IsAny <TurnContext>(), It.IsAny <bool>(), It.IsAny <CancellationToken>()), Times.Once);
            mockUserState.Verify(x => x.SaveChangesAsync(It.IsAny <TurnContext>(), It.IsAny <bool>(), It.IsAny <CancellationToken>()), Times.Once);
        }
示例#12
0
        private void CacheTestFlowConfig()
        {
            cListTestFlow = new List <TestFlow>();

            for (int i = 0; i < dgvTestFlow.Rows.Count; i++)
            {
                TestFlow testFlow = new TestFlow();
                testFlow.ID           = Convert.ToInt32(dgvTestFlow.Rows[i].Cells["ID"].Value);
                testFlow.TestNumber   = Convert.ToInt32(dgvTestFlow.Rows[i].Cells["TestNumber"].Value);
                testFlow.TestName     = Convert.ToString(dgvTestFlow.Rows[i].Cells["TestName"].Value);
                testFlow.TestFunction = Convert.ToString(dgvTestFlow.Rows[i].Cells["TestFunction"].Value);
                testFlow.UpperLimit   = Convert.ToDouble(dgvTestFlow.Rows[i].Cells["UpperLimit"].Value);
                testFlow.LowerLimit   = Convert.ToDouble(dgvTestFlow.Rows[i].Cells["LowerLimit"].Value);
                testFlow.Unit         = Convert.ToString(dgvTestFlow.Rows[i].Cells["Unit"].Value);
                testFlow.SoftBin      = Convert.ToInt32(dgvTestFlow.Rows[i].Cells["SoftBin"].Value);
                testFlow.HardBin      = Convert.ToInt32(dgvTestFlow.Rows[i].Cells["HardBin"].Value);
                testFlow.Action       = Convert.ToString(dgvTestFlow.Rows[i].Cells["Action"].Value);

                if (cParamsByID.Any(x => x.Key == testFlow.ID))
                {
                    testFlow.TestFunctionParameters = cParamsByID[testFlow.ID];
                }

                cListTestFlow.Add(testFlow);
            }
        }
示例#13
0
        public void Setup()
        {
            test = new TestFlow();
            test.Setup();

            interstialFirstStepFlow = new InterstialFirstStepFlow();
            interstialFirstStepFlow.Setup();
        }
        public static TestFlow Do(this TestFlow testFlow, Action action)
        {
            return(new TestFlow(
                       async() =>
            {
                await testFlow.StartTestAsync().ConfigureAwait(false);

                action?.Invoke();
            },
                       testFlow));
        }
示例#15
0
        private void LoadTestFlowConfig(XmlNode xnScequencer)
        {
            dgvTestFlow.Rows.Clear();
            cParamsByID.Clear();
            oListTestFlow = new List <TestFlow>();
            XmlNode xnTestFlow = xnScequencer.SelectSingleNode("testflowconfig");

            foreach (XmlNode xn in xnTestFlow.ChildNodes)
            {
                TestFlow testFlow = new TestFlow();
                testFlow.ID = Convert.ToInt32(xn.SelectSingleNode("id").InnerText);
                cParamsByID.Add(testFlow.ID, new List <FunctionParameter>());
                testFlow.TestNumber   = Convert.ToInt32(xn.SelectSingleNode("testnumber").InnerText);
                testFlow.TestName     = xn.SelectSingleNode("testname").InnerText;
                testFlow.TestFunction = xn.SelectSingleNode("testfunction").InnerText;
                testFlow.UpperLimit   = Convert.ToDouble(xn.SelectSingleNode("upperlimit").InnerText);
                testFlow.LowerLimit   = Convert.ToDouble(xn.SelectSingleNode("lowerlimit").InnerText);
                testFlow.Unit         = xn.SelectSingleNode("unit").InnerText;
                testFlow.SoftBin      = Convert.ToInt32(xn.SelectSingleNode("softbin").InnerText);
                testFlow.HardBin      = Convert.ToInt32(xn.SelectSingleNode("hardbin").InnerText);
                testFlow.Action       = xn.SelectSingleNode("action").InnerText;

                XmlNode xnTestFunctionParameters = xn.SelectSingleNode("testfunctionparameters");
                foreach (XmlNode x in xnTestFunctionParameters)
                {
                    FunctionParameter fp = new FunctionParameter();
                    fp.ParameterName  = x.SelectSingleNode("parametername").InnerText;
                    fp.ParameterType  = x.SelectSingleNode("parametertype").InnerText;
                    fp.ParameterValue = x.SelectSingleNode("parametervalue").InnerText;
                    testFlow.TestFunctionParameters.Add(fp);
                    cParamsByID[testFlow.ID].Add(fp);
                }

                oListTestFlow.Add(testFlow);

                int index = dgvTestFlow.Rows.Add();
                dgvTestFlow.Rows[index].Cells["ID"].Value           = testFlow.ID;
                dgvTestFlow.Rows[index].Cells["TestNumber"].Value   = testFlow.TestNumber;
                dgvTestFlow.Rows[index].Cells["TestName"].Value     = testFlow.TestName;
                dgvTestFlow.Rows[index].Cells["TestFunction"].Value = testFlow.TestFunction;
                dgvTestFlow.Rows[index].Cells["UpperLimit"].Value   = testFlow.UpperLimit;
                dgvTestFlow.Rows[index].Cells["LowerLimit"].Value   = testFlow.LowerLimit;
                dgvTestFlow.Rows[index].Cells["Unit"].Value         = testFlow.Unit;
                dgvTestFlow.Rows[index].Cells["SoftBin"].Value      = testFlow.SoftBin;
                dgvTestFlow.Rows[index].Cells["HardBin"].Value      = testFlow.HardBin;
                dgvTestFlow.Rows[index].Cells["Action"].Value       = testFlow.Action;
            }

            dgvTestFlow.ClearSelection();

            //Todo: Delete this later
            cListTestFlow = oListTestFlow;
        }
示例#16
0
        public TestFlow GetTestFlow()
        {
            var adapter = new TestAdapter()
                          .Use(new AutoSaveStateMiddleware(UserState, ConversationState));

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

            return(testFlow);
        }
        protected 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);
        }
        private static TestFlow CreateMultiAuthDialogTestFlow()
        {
            var convoState  = new ConversationState(new MemoryStorage());
            var dialogState = convoState.CreateProperty <DialogState>("dialogState");

            var adapter = new TestAdapter()
                          .Use(new AutoSaveStateMiddleware(convoState));

            var testFlow = new TestFlow(adapter, async(turnContext, cancellationToken) =>
            {
                var state   = await dialogState.GetAsync(turnContext, () => new DialogState(), cancellationToken);
                var dialogs = new DialogSet(dialogState);

                // Adapter add token
                adapter.AddUserToken("Test", "test", "test", "test");

                // Add MicrosoftAPPId to configuration
                var listOfOauthConnections = new List <OAuthConnection> {
                    new OAuthConnection {
                        Name = "Test", Provider = "Test"
                    }
                };
                var steps = new WaterfallStep[]
                {
                    GetAuthTokenAsync,
                    AfterGetAuthTokenAsync,
                };
                dialogs.Add(new MultiProviderAuthDialog(listOfOauthConnections));
                dialogs.Add(new WaterfallDialog("Auth", steps));

                var dc = await dialogs.CreateContextAsync(turnContext, cancellationToken);

                var results = await dc.ContinueDialogAsync(cancellationToken);
                if (results.Status == DialogTurnStatus.Empty)
                {
                    results = await dc.BeginDialogAsync("Auth", null, cancellationToken);
                }

                if (results.Status == DialogTurnStatus.Cancelled)
                {
                    await turnContext.SendActivityAsync(MessageFactory.Text($"Component dialog cancelled (result value is {results.Result?.ToString()})."), cancellationToken);
                }
                else if (results.Status == DialogTurnStatus.Complete)
                {
                    var value = (int)results.Result;
                    await turnContext.SendActivityAsync(MessageFactory.Text($"Bot received the number '{value}'."), cancellationToken);
                }
            });

            return(testFlow);
        }
        public async Task ConversationStateTest()
        {
            var testName   = "ConversationStateTest";
            var activities = TranscriptUtilities.GetActivitiesFromFile(ClassName, testName);

            var storage = new MemoryStorage();

            var convoState   = new ConversationState(new MemoryStorage());
            var testProperty = convoState.CreateProperty <ConversationStateObject>("test");

            var adapter = new TestAdapter(TestAdapter.CreateConversation(testName))
                          .Use(new AutoSaveStateMiddleware(convoState));

            var flow = new TestFlow(adapter, async(context, cancellationToken) =>
            {
                if (context.Activity.Type == ActivityTypes.Message)
                {
                    var(command, value) = GetCommandValue(context);
                    switch (command)
                    {
                    case "delete":
                        await testProperty.DeleteAsync(context);
                        break;

                    case "set":
                        {
                            var data   = await testProperty.GetAsync(context, () => new ConversationStateObject());
                            data.Value = value;
                            await testProperty.SetAsync(context, data);
                        }

                        break;

                    case "read":
                        {
                            var data = await testProperty.GetAsync(context, () => new ConversationStateObject());
                            await context.SendActivityAsync($"value:{data.Value}");
                        }

                        break;

                    default:
                        await context.SendActivityAsync("bot message");
                        break;
                    }
                }
            });

            await flow.Test(activities).StartTestAsync();
        }
示例#20
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);
        }
        protected TestFlow GetTestFlow()
        {
            var sp = Services.BuildServiceProvider();
            var adapter = sp.GetService<TestAdapter>();
            adapter.AddUserToken(AuthenticationProvider, adapter.Conversation.ChannelId, adapter.Conversation.User.Id, TestToken, MagicCode);

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

            return testFlow;
        }
示例#22
0
        /// <summary>
        /// Create a TestFlow which spins up a SkillDialog ready for the tests to execute against.
        /// </summary>
        /// <param name="locale">Change the locale of generated activities.</param>
        /// <returns>TestFlow.</returns>
        public TestFlow GetTestFlow(string locale = null)
        {
            var adapter = new TestAdapter(sendTraceActivity: true)
                          .Use(new AutoSaveStateMiddleware(this.ConversationState));

            var testFlow = new TestFlow(adapter, async(context, token) =>
            {
                var bot = this.BuildBot() as VirtualAssistant;

                await bot.OnTurnAsync(context, CancellationToken.None);
            });

            return(testFlow);
        }
示例#23
0
        public TestFlow GetTestFlow()
        {
            var adapter = new TestAdapter()
                          .Use(new AutoSaveStateMiddleware(this.ConversationState));

            var testFlow = new TestFlow(adapter, async(context, token) =>
            {
                var bot   = this.BuildBot() as AutomotiveSkill.AutomotiveSkill;
                var state = await this.AutomotiveSkillStateAccessor.GetAsync(context, () => new AutomotiveSkillState());
                await bot.OnTurnAsync(context, CancellationToken.None);
            });

            return(testFlow);
        }
示例#24
0
        public TestFlow GetTestFlow()
        {
            var adapter = new TestAdapter()
                          .Use(new AutoSaveStateMiddleware(ConversationState))
                          .Use(new EventDebuggerMiddleware());

            var testFlow = new TestFlow(adapter, async(context, token) =>
            {
                var bot = BuildBot() as PointOfInterestSkill.PointOfInterestSkill;
                await bot.OnTurnAsync(context, CancellationToken.None);
            });

            return(testFlow);
        }
示例#25
0
        public TestFlow GetTestFlow()
        {
            var sp      = Services.BuildServiceProvider();
            var adapter = sp.GetService <TestAdapter>();

            adapter.AddUserToken(Provider, Channels.Test, adapter.Conversation.User.Id, "test");

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

            return(testFlow);
        }
示例#26
0
        protected TestFlow GetTestFlow()
        {
            var sp      = Services.BuildServiceProvider();
            var adapter = sp.GetService <TestAdapter>();

            StartActivity = Activity.CreateConversationUpdateActivity();
            StartActivity.MembersAdded = new ChannelAccount[] { adapter.Conversation.User, adapter.Conversation.Bot };

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

            return(testFlow);
        }
示例#27
0
        public TestFlow GetTestFlow()
        {
            var sp                = Services.BuildServiceProvider();
            var adapter           = sp.GetService <TestAdapter>();
            var conversationState = sp.GetService <ConversationState>();
            var stateAccessor     = conversationState.CreateProperty <AutomotiveSkillState>(nameof(AutomotiveSkillState));

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

            return(testFlow);
        }
示例#28
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>();
                var state         = await CalendarStateAccessor.GetAsync(context, () => new CalendarSkillState());
                state.APIToken    = "test";
                state.EventSource = EventSource.Microsoft;
                await bot.OnTurnAsync(context, CancellationToken.None);
            });

            return(testFlow);
        }
示例#29
0
        public TestFlow GetTestFlow()
        {
            var adapter = new TestAdapter()
                          .Use(new AutoSaveStateMiddleware(this.ConversationState));

            var testFlow = new TestFlow(adapter, async(context, token) =>
            {
                var bot           = this.BuildBot() as CalendarSkill.CalendarSkill;
                var state         = await this.CalendarStateAccessor.GetAsync(context, () => new CalendarSkillState());
                state.APIToken    = "test";
                state.EventSource = EventSource.Microsoft;
                await bot.OnTurnAsync(context, CancellationToken.None);
            });

            return(testFlow);
        }
示例#30
0
        public TestFlow GetTestFlow()
        {
            var adapter = new TestAdapter()
                .Use(new AutoSaveStateMiddleware(this.ConversationState));

            var testFlow = new TestFlow(adapter, async (context, token) =>
            {
                var bot = this.BuildBot() as EmailSkill.EmailSkill;

                var state = await this.EmailStateAccessor.GetAsync(context, () => new EmailSkillState());
                state.MailSourceType = MailSource.Microsoft;

                await bot.OnTurnAsync(context, CancellationToken.None);
            });

            return testFlow;
        }