public void TestGetFunctionFromCommandStringReturnsNullIfNoDesiredActionCanBeDetermined() { ActionRouter.SetUp(); const string commandString = "Made you look!"; Assert.IsNull(ActionRouter.GetFunctionFromCommandString(commandString)); }
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); }
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); } }