private async Task <DeviceCommand> CallLuisAsync(string input) { var parsedMessage = await luisClient.parseInput(input); CommandBase command; switch (parsedMessage.topScoringIntent.intent) { case "Count": command = new CountCommand(parsedMessage.entities); break; case "Location": command = new LocationCommand(parsedMessage.entities); break; case "Calculation": command = new CalculationCommand(parsedMessage.entities); break; case "Timer": command = new TimerCommand(parsedMessage.entities); break; default: command = new NoneCommand(); break; } return(await command.Run()); }
public void TestLocationValidation5() { LocationCommand locationCommand = new LocationCommand("5 5 N"); Area.EndLocation = new Location(6, 5); Assert.AreEqual(true, locationCommand.Validate()); }
public void TestLocationValidation1() { LocationCommand locationCommand = new LocationCommand("A 5"); Area.EndLocation = new Location(6, 5); Assert.AreEqual(false, locationCommand.Validate()); }
public void EditLocation(LocationCommand command) { var checkLocation = _db.Diadiemduliches.FirstOrDefault(n => n.ID == command.ID); { checkLocation.Tendiadiem = command.Tendiadiem; checkLocation.Mota = command.Mota; checkLocation.MienID = command.MienID; } _db.SaveChanges(); }
public void AddLocation(LocationCommand locationCommand) { //var newStaff = new Nguoidung(); var newLocation = new Diadiemdulich(); { newLocation.Tendiadiem = locationCommand.Tendiadiem; newLocation.Mota = locationCommand.Mota; newLocation.MienID = locationCommand.MienID; } _db.Diadiemduliches.Add(newLocation); _db.SaveChanges(); }
public void LocationCommand_Should_UpdateLocation() { PlayerStatusRepository repository = CreatePlayerStatusRepository(); LocationCommand sut = CreateSut(repository); repository.SetLocation(Build.A.StarSystem.Name); string expectedSystem = Build.A.StarSystem.Name; TestEvent loadEvent = Build.An.Event.WithEvent("LoadGame").WithPayload("StarSystem", expectedSystem); sut.Handle(loadEvent); repository.Location.Should().Be(expectedSystem); }
public IActionResult EditLocation(LocationCommand command, Mien mien) { int SelectValue = mien.ID; ViewBag.SelectedValue = mien.ID; List <Mien> listMien = new List <Models.db.Mien>(); listMien = (from t in _db.Miens select t).ToList(); //listMien.Insert(0, new Mien { ID = 0, Tenmien = "Chọn miền" }); ViewBag.ListMien = listMien; var model = this._locationService.SeeLocation(command.ID); model.Tendiadiem = command.Tendiadiem; model.Mota = command.Mota; if (ModelState.IsValid) { this._locationService.EditLocation(command); return(RedirectToAction("AllLocation", "Admin")); } return(View(model)); }
public IActionResult AddLocation(LocationCommand command, Mien mien) { //ViewBag.Tinh = new SelectList(_db.Miens.ToList()); if (ModelState.IsValid) { this._locationService.AddLocation(command); return(RedirectToAction("AllLocation", "Admin")); } //if (command.ID == 0) //{ // ModelState.AddModelError("", "Chọn miền"); //} int SelectValue = mien.ID; ViewBag.SelectedValue = mien.ID; List <Mien> listMien = new List <Models.db.Mien>(); listMien = (from t in _db.Miens select t).ToList(); //listMien.Insert(0, new Mien { ID = 0, Tenmien = "Chọn miền" }); ViewBag.ListMien = listMien; return(View()); }
public string ProcessCommand(string content) { var requestData = JsonConvert.DeserializeObject <Command>(content); var command = requestData.Name; var parameters = requestData.Parameters; string elementId = null; if (parameters == null) { throw new NullReferenceException("Parameters can not be NULL"); } JToken elementIdObject; if (parameters.TryGetValue("ID", out elementIdObject)) { elementId = elementIdObject.ToString(); } CommandBase commandToExecute; if (command.Equals("ping")) { // Service command return("<pong>"); } // TODO: Refactor similar to CommandExecutors in Driver if (command.Equals(DriverCommand.GetAlertText)) { commandToExecute = new AlertTextCommand(); } else if (command.Equals(DriverCommand.AcceptAlert)) { commandToExecute = new AlertCommand { Action = AlertCommand.With.Accept }; } else if (command.Equals(DriverCommand.DismissAlert)) { commandToExecute = new AlertCommand { Action = AlertCommand.With.Dismiss }; } else if (command.Equals(DriverCommand.FindElement) || command.Equals(DriverCommand.FindChildElement)) { commandToExecute = new ElementCommand { ElementId = elementId }; } else if (command.Equals(DriverCommand.FindElements) || command.Equals(DriverCommand.FindChildElements)) { commandToExecute = new ElementsCommand { ElementId = elementId }; } else if (command.Equals(DriverCommand.ClickElement)) { commandToExecute = new ClickCommand { ElementId = elementId }; } else if (command.Equals(DriverCommand.SendKeysToElement)) { var values = ((JArray)parameters["value"]).ToObject <List <string> >(); var value = string.Empty; if (values.Any()) { value = values.Aggregate((aggregated, next) => aggregated + next); } commandToExecute = new ValueCommand { ElementId = elementId, KeyString = value }; } else if (command.Equals(DriverCommand.GetElementText)) { commandToExecute = new TextCommand { ElementId = elementId }; } else if (command.Equals(DriverCommand.IsElementDisplayed)) { commandToExecute = new DisplayedCommand { ElementId = elementId }; } else if (command.Equals(DriverCommand.GetElementLocation)) { commandToExecute = new LocationCommand { ElementId = elementId }; } else if (command.Equals(DriverCommand.GetElementLocationOnceScrolledIntoView)) { commandToExecute = new LocationInViewCommand { ElementId = elementId }; } else if (command.Equals(DriverCommand.GetElementSize)) { commandToExecute = new GetElementSizeCommand { ElementId = elementId }; } else if (command.Equals(DriverCommand.GetElementRect)) { commandToExecute = new GetElementRectCommand { ElementId = elementId }; } else if (command.Equals(DriverCommand.GetPageSource)) { commandToExecute = new PageSourceCommand { ElementId = elementId }; } else if (command.Equals(DriverCommand.GetOrientation)) { commandToExecute = new OrientationCommand(); } else if (command.Equals(DriverCommand.GetElementAttribute)) { commandToExecute = new GetElementAttributeCommand { ElementId = elementId }; } else if (command.Equals(DriverCommand.ExecuteScript)) { commandToExecute = new ExecuteCommand(); } else if (command.Equals(ExtendedDriverCommand.InvokeAppBarItemCommand)) { commandToExecute = new InvokeAppBarItemCommand(); } else if (command.Equals(ExtendedDriverCommand.InvokeMethodCommand)) { commandToExecute = new InvokeMethodCommand(); } else { throw new NotImplementedException("Not implemented: " + command); } // TODO: Replace passing Automator to command with passing some kind of configuration commandToExecute.Automator = this; commandToExecute.Parameters = parameters; var response = commandToExecute.Do(); return(response); }
public LocationVM() { LocationCommand = new LocationCommand(this); Location = new Model.Location(); }