public void TestGetFunctionFromCommandStringReturnsNullIfNoDesiredActionCanBeDetermined() { ActionRouter.SetUp(); const string commandString = "Made you look!"; Assert.IsNull(ActionRouter.GetFunctionFromCommandString(commandString)); }
public void Start() { _indexer = CreateIndexer(); _graphIndexer = CreateGraphIndexer(); _actionRouter = CreateActionRouter(); ConnectToEventstore(); }
private ActionRouter CreateActionRouter() { var actionRouter = new ActionRouter(); actionRouter.Add <CustomerCreated>(Handle); actionRouter.Add <ProductCreated>(Handle); actionRouter.Add <OrderPlaced>(_graphIndexer.AddOrder); return(actionRouter); }
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; }
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; }
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); }
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); }
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"); }
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); }
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); } }
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(); }
private void HandleActions() { ActionRouter = new ActionRouter(RootLogger, Communication); }