public void GetUnlockLimitedAccessFeatureTest()
        {
            try
            {
                MVARegistrationHelpers.UnlockLimitedAccessFeature();

                Assert.IsTrue(true);
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(MethodAccessException));
                Assert.Fail($"UnlockLimitedAccessFeature failed with exception: {ex.Message}");
            }
        }
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            Task.Run(async() => await LocalSettingsHelper.InitializeAsync()).Wait();

            MVARegistrationHelpers.UnlockLimitedAccessFeature();
            LogRouter.Initialize();

            this.keywordRegistration = new KeywordRegistration(new Version(1, 0, 0, 0));

            this.agentSessionManager = new AgentSessionManager();

            //var _ = this.UpdateSessionAsync();
            _ = this.DoKeywordSetupAsync();
            MVARegistrationHelpers.IsBackgroundTaskRegistered = true;
        }
Beispiel #3
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            MVARegistrationHelpers.UnlockLimitedAccessFeature();
            LogRouter.Initialize();

            this.keywordRegistration = new KeywordRegistration(
                "Contoso",
                "{C0F1842F-D389-44D1-8420-A32A63B35568}",
                "1033",
                "MICROSOFT_KWSGRAPH_V1",
                "ms-appx:///MVAKeywords/Contoso.bin",
                new Version(1, 0, 0, 0),
                "ms-appx:///SDKKeywords/Contoso.table");

            this.agentSessionManager = new AgentSessionManager();

            //var _ = this.UpdateSessionAsync();
            _ = this.DoKeywordSetupAsync();
            MVARegistrationHelpers.IsBackgroundTaskRegistered = true;
        }
        public async Task TestMethodSetup()
        {
            MVARegistrationHelpers.UnlockLimitedAccessFeature();

            this.speechRecognizingEvents             = new List <string>();
            this.speechRecognizedEvents              = new List <string>();
            this.signalRejectedEvents                = new List <string>();
            this.signalConfirmedEvents               = new List <string>();
            this.keywordRecognizingEvents            = new List <string>();
            this.keywordRecognizedEvents             = new List <string>();
            this.dialogResponseReceivedEvents        = new List <DialogResponse>();
            this.speechRecognizingEventReceived      = new AutoResetEvent(false);
            this.speechRecognizedEventReceived       = new AutoResetEvent(false);
            this.dialogResponseReceivedEventReceived = new AutoResetEvent(false);
            this.keywordRecognizingEventReceived     = new AutoResetEvent(false);
            this.keywordRecognizedEventReceived      = new AutoResetEvent(false);
            this.signalRejectedEventReceived         = new AutoResetEvent(false);
            this.signalConfirmedEventReceived        = new AutoResetEvent(false);

            this.mockBackend             = new MockDialogBackend();
            this.mockKeywordRegistration = new MockKeywordRegistration();
            this.mockAgentSessionManager = new MockAgentSessionManager();
            this.dialogManager           = await DialogManagerShim.CreateMockManagerAsync(this.mockBackend, this.mockKeywordRegistration, this.mockAgentSessionManager);

            this.dialogManager.SpeechRecognizing += (s, e) =>
            {
                this.speechRecognizingEvents.Add(e);
                this.speechRecognizingEventReceived.Set();
            };
            this.dialogManager.SpeechRecognized += (s, e) =>
            {
                this.speechRecognizedEvents.Add(e);
                this.speechRecognizedEventReceived.Set();
            };
            this.dialogManager.DialogStateChanged += (before, after) =>
            {
                if (before == ConversationalAgentState.Inactive && after == ConversationalAgentState.Listening)
                {
                    // Shouldn't have received anything yet; just started
                    Assert.IsTrue(this.speechRecognizingEvents.Count == 0);
                    Assert.IsTrue(this.speechRecognizedEvents.Count == 0);
                    Assert.IsTrue(this.dialogResponseReceivedEvents.Count == 0);
                }
                else if (before == ConversationalAgentState.Listening && after == ConversationalAgentState.Working)
                {
                    // Transition should happen to working (and block!) BEFORE we get the recognized event
                    Assert.IsTrue(this.speechRecognizingEvents.Count != 0);
                    Assert.IsTrue(this.speechRecognizedEvents.Count == 0);
                    Assert.IsTrue(this.dialogResponseReceivedEvents.Count == 0);
                }
                else if (before == ConversationalAgentState.Working && after == ConversationalAgentState.Inactive)
                {
                    Assert.IsTrue(this.dialogResponseReceivedEvents.Count != 0);
                }
                else if (before == ConversationalAgentState.Inactive && after == ConversationalAgentState.Inactive)
                {
                    Debug.WriteLine($"Weird transition: Inactive to Inactive");
                }
                else if (before == ConversationalAgentState.Inactive && after == ConversationalAgentState.Detecting)
                {
                    Debug.WriteLine($"Transition from inactive to detecting");
                }
                else if (before == ConversationalAgentState.Detecting && after == ConversationalAgentState.Inactive)
                {
                    Debug.WriteLine($"Transition from detecting to inactive");
                }
                else if (before == ConversationalAgentState.Listening && after == ConversationalAgentState.Detecting)
                {
                    Debug.WriteLine($"Transition from listening To detecting");
                    Assert.IsTrue(this.signalConfirmedEvents.Count == 0);
                }
                else if (before == ConversationalAgentState.Listening && after == ConversationalAgentState.Listening)
                {
                    Debug.WriteLine($"Transition from listenting to listening");
                    Assert.IsTrue(this.signalConfirmedEvents.Count != 0);
                    Assert.IsTrue(this.keywordRecognizedEvents.Count != 0);
                }
                else if (before == ConversationalAgentState.Detecting && after == ConversationalAgentState.Listening)
                {
                    Debug.WriteLine($"Transition from detecting to listening");
                }
                else if (before == ConversationalAgentState.Listening && after == ConversationalAgentState.Inactive)
                {
                    Debug.WriteLine($"Transition from listening to inactive");
                }
                else
                {
                    Assert.Fail($"Unexpected state transition: {before.ToString()} to {after.ToString()}");
                }
            };
            this.dialogManager.DialogResponseReceived += (s, e) =>
            {
                this.dialogResponseReceivedEvents.Add(e);
                this.dialogResponseReceivedEventReceived.Set();
            };

            this.dialogManager.SignalRejected += (e) =>
            {
                this.signalRejectedEvents.Add(e.ToString());
                this.signalRejectedEventReceived.Set();
            };

            this.dialogManager.SignalConfirmed += (e) =>
            {
                this.signalConfirmedEvents.Add(e.ToString());
                this.keywordRecognizingEvents.Add(e.ToString());
                this.keywordRecognizedEvents.Add(e.ToString());
                this.signalConfirmedEventReceived.Set();
                this.keywordRecognizingEventReceived.Set();
                this.keywordRecognizedEventReceived.Set();
            };
        }