예제 #1
0
        public void TestGetFunctionFromCommandStringReturnsNullIfNoDesiredActionCanBeDetermined()
        {
            ActionRouter.SetUp();
            const string commandString = "Made you look!";

            Assert.IsNull(ActionRouter.GetFunctionFromCommandString(commandString));
        }
예제 #2
0
 public void Start()
 {
     _indexer      = CreateIndexer();
     _graphIndexer = CreateGraphIndexer();
     _actionRouter = CreateActionRouter();
     ConnectToEventstore();
 }
예제 #3
0
        private ActionRouter CreateActionRouter()
        {
            var actionRouter = new ActionRouter();

            actionRouter.Add <CustomerCreated>(Handle);
            actionRouter.Add <ProductCreated>(Handle);
            actionRouter.Add <OrderPlaced>(_graphIndexer.AddOrder);
            return(actionRouter);
        }
예제 #4
0
파일: MainPage.xaml.cs 프로젝트: ploiu/Bob
 public MainPage()
 {
     this.InitializeComponent();
     // hide the main menu
     this.MenuColumn.Width = new GridLength(0);
     ActionRouter.SetUp();
     // prevent the application from closing when the user hits the x button. This will alarms and notifications to still trigger FIXME we will have to figure something out since apps can't be published to the store with a restricted capability
     //SystemNavigationManagerPreview.GetForCurrentView().CloseRequested += CloseHandle;
     Window.Current.SizeChanged += SizeChangedHandler;
 }
예제 #5
0
 public MainPage()
 {
     this.InitializeComponent();
     // hide the main menu
     this.MenuColumn.Width = new GridLength(0);
     ActionRouter.SetUp();
     // prevent the application from closing when the user hits the x button. This will alarms and notifications to still trigger
     SystemNavigationManagerPreview.GetForCurrentView().CloseRequested += CloseHandle;
     Window.Current.SizeChanged += SizeChangedHandler;
 }
예제 #6
0
        public void TestGetFunctionFromCommandStringReturnsExpectedFunctionWhenShallowFunction()
        {
            // tests that the GetFunctionFromCommandString function still works even if it's not working on a nested Dictionary
            ActionRouter.SetUp();
            const string commandString = "Get the weather for tomorrow";
            Func <string, BobTheDigitalAssistant.Actions.Action> returnedFunction = ActionRouter.GetFunctionFromCommandString(commandString);

            Assert.IsNotNull(returnedFunction);
            WeatherAction returnedAction = (WeatherAction)returnedFunction(commandString);

            Assert.IsNotNull(returnedAction);
        }
예제 #7
0
        public void TestGetFunctionFromCommandStringReturnsExpectedFunction()
        {
            // setup the action router
            ActionRouter.SetUp();
            // the command string
            const string commandString = "Set an alarm for 5:30 A.M.";
            Func <string, BobTheDigitalAssistant.Actions.Action> returnedFunction = ActionRouter.GetFunctionFromCommandString(commandString);

            Assert.IsNotNull(returnedFunction);
            AlarmAction returnedAction = (AlarmAction)returnedFunction(commandString);

            // check the alarm action's values
            Assert.AreEqual(AlarmAction.AlarmActionTypes.CREATE, returnedAction.ActionType);
        }
예제 #8
0
        public void TestGetNextNodeInChainReturnsValueAttachedToFoundKeyword()
        {
            const string keyword     = "piano";
            string       inputString = $"this is the input string, and the keyword is {keyword}";
            // create the dictionary of the values, mimicking the case insensitivity the original dictionary has
            Dictionary <string, dynamic> inputDict = new Dictionary <string, dynamic>();

            inputDict.Add("notIt", "whatever");
            inputDict.Add("weather", "whatever");
            inputDict.Add("Piano", "correct value");
            inputDict.Add("alarms", "whatever");
            inputDict.Add("reminders", "whatever");
            var value = ActionRouter.GetNextNodeInChain(inputString, inputDict);

            Assert.AreEqual(value, "correct value");
        }
예제 #9
0
        public void TestFindKeywordReturnsNullIfKeywordIsNotFound()
        {
            const string keyword     = "pianoforte";
            string       inputString = $"this is the input string, and the keyword is {keyword}";
            // create the dictionary of the values
            Dictionary <string, dynamic> inputDict = new Dictionary <string, dynamic>();

            inputDict.Add("notIt", "whatever");
            inputDict.Add("weather", "whatever");
            // the uppercase P tests case insensitivity
            inputDict.Add("Piano", "whatever");
            inputDict.Add("alarms", "whatever");
            inputDict.Add("reminders", "whatever");
            string matchingKeyword = ActionRouter.FindKeyword(inputString, inputDict);

            Assert.IsNull(matchingKeyword);
        }
예제 #10
0
파일: MainPage.xaml.cs 프로젝트: ploiu/Bob
        private void performActionFromCommandBoxText(string text)
        {
            // get the action for the text in the text box
            Func <string, BobTheDigitalAssistant.Actions.Action> actionPrimer = ActionRouter.GetFunctionFromCommandString(text);

            if (actionPrimer != null)
            {
                BobTheDigitalAssistant.Actions.Action action = actionPrimer.Invoke(text);
                action.PerformAction(this.media, this.DynamicArea);
            }
            else
            {
                // TODO pull this response from the database once the story to create bob responses is done
                string message = "Sorry, I don't understand.";
                string ssml    = new SSMLBuilder().Prosody(message, contour: "(5%, +10%) (30%, -10%) (80%, +0.5%)").Build();
                TextToSpeechEngine.SpeakInflectedText(this.media, ssml);
            }
        }
예제 #11
0
파일: MainPage.xaml.cs 프로젝트: ploiu/Bob
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (!ActionRouter.IsSetup)
            {
                ActionRouter.SetUp();
            }
            // if bob has not been introduced, then introduce him now
            var hasIntroducedBob = StoredProcedures.QuerySettingByName("_ToldUserHowToUseBob");

            if (hasIntroducedBob.GetSelectedOption() != null && hasIntroducedBob.GetSelectedOption().DisplayName == "false")
            {
                this.IntroduceBob();
                hasIntroducedBob.SelectOption("true");
                StoredProcedures.SelectOption(hasIntroducedBob.SettingID, hasIntroducedBob.GetSelectedOption().OptionID);
            }
            AudioPlayer.Start();
            // if the user has elected to have speech recognition turned on, then request for microphone permissions
            this.RequestMicrophoneAcessIfUserWantsVoiceDetection();
        }
예제 #12
0
 private void HandleActions()
 {
     ActionRouter = new ActionRouter(RootLogger, Communication);
 }