private void loadListRowIntoDetails(int RowIndex) { DataGridViewRow row = gvMenuItems.Rows[RowIndex]; activeID = int.Parse(row.Cells[0].Value.ToString()); data_models.Models.MenuItem m = MenuItemController.GetOneById(_context, (int)activeID); ddlCategory.Text = m.Category; tbxTitle.Text = m.Title; if (m.Description != null) { rtbDescription.Text = m.Description; } if (m.Price != null) { tbxPrice.Text = toPaddedString((decimal)m.Price); } if (m.DiscountPrice == null) { cbxDiscount.Checked = false; } else { cbxDiscount.Checked = true; tbxDiscountPrice.Text = toPaddedString((decimal)m.DiscountPrice); } cbxAvailable.Checked = m.IsAvailable; cbxSpecialty.Checked = m.IsSpecialty; }
public void Delete_Not_Ajax_Request() { // Arrange var id = 1; var menuItem = new MenuItem() { ID = 1, Position = 1, Title = "Strona główna", ActionName = "Index", ControllerName = "Home" }; var service = Substitute.For <IMenuItemRepository>(); var mapper = Substitute.For <IMapper>(); var fakeController = new FakeController(); var controller = new MenuItemController(service, mapper); fakeController.PrepareFakeRequest(); controller.ControllerContext = fakeController.GetControllerContext <MenuItemController>(new RouteData(), controller); service.Get(id).Returns(menuItem); // Act var result = controller.Delete(id) as RedirectToRouteResult; var ajaxRequest = controller.Request.IsAjaxRequest(); var actionName = result.RouteValues.Values.ElementAt(0); // Assert Assert.That(result, !Is.Null); Assert.That(ajaxRequest, Is.False); Assert.That("Index", Is.EqualTo(actionName)); }
public void Good_Delete() { // Arrange var id = 1; var menuItem = new MenuItem() { ID = 1, Position = 1, Title = "Strona główna", ActionName = "Index", ControllerName = "Home" }; var service = Substitute.For <IMenuItemRepository>(); var mapper = Substitute.For <IMapper>(); var fakeController = new FakeController(); var controller = new MenuItemController(service, mapper); fakeController.PrepareFakeAjaxRequest(); controller.ControllerContext = fakeController.GetControllerContext <MenuItemController>(new RouteData(), controller); service.Get(id).Returns(menuItem); service.Delete(menuItem); service.Save(); // Act var result = controller.Delete(id) as JsonResult; var ajaxRequest = controller.Request.IsAjaxRequest(); var jsonRequestBehavior = result.JsonRequestBehavior; var data = result.Data; // Assert Assert.That(result, !Is.Null); Assert.That(ajaxRequest, Is.True); Assert.That(JsonRequestBehavior.AllowGet, Is.EqualTo(jsonRequestBehavior)); Assert.That("", Is.EqualTo(data)); }
public void Post_Edit_Is_Not_Valid() { // Arrange var menuItemViewModel = new MenuItemViewModel() { ID = 1, //Position = 1, Title = "Strona główna", //ActionName = "Index", ControllerName = "Home" }; var service = Substitute.For <IMenuItemRepository>(); var mapper = Substitute.For <IMapper>(); var controller = new MenuItemController(service, mapper); var validator = new ModelValidator <MenuItemViewModel>(menuItemViewModel); // Act var valid = validator.IsValid(); validator.AddToModelError(controller); var result = controller.Edit(menuItemViewModel) as RedirectToRouteResult; var actionName = result.RouteValues.Values.ElementAt(0); var tempData = controller.TempData["ModelIsNotValid"]; // Assert Assert.That(result, !Is.Null); Assert.That(valid, Is.False); Assert.That("Index", Is.EqualTo(actionName)); }
public void Post_Edit_Model_Is_Null() { // Arrange var id = -1; MenuItem menuItem = null; var menuItemViewModel = new MenuItemViewModel() { ID = 1, Position = 1, Title = "Strona glowna", ActionName = "Index", ControllerName = "Home" }; var service = Substitute.For <IMenuItemRepository>(); var mapper = Substitute.For <IMapper>(); var validator = new ModelValidator <MenuItemViewModel>(menuItemViewModel); var controller = new MenuItemController(service, mapper); service.Get(id).Returns(menuItem); // Act var valid = validator.IsValid(); validator.AddToModelError(controller); var result = controller.Edit(menuItemViewModel) as HttpNotFoundResult; var statusCode = result.StatusCode; // Assert Assert.That(result, !Is.Null); Assert.That(valid, Is.True); Assert.That(404, Is.EqualTo(statusCode)); }
public void SetSelected(MenuItemController menuItem) { if (selectedMenuItem != null) { selectedMenuItem.Activate(); } selectedMenuItem = menuItem; }
private void setHolding(GameObject item = null) { currHolding = item; if (!currHolding) { itemController = item.GetComponent <MenuItemController>(); } }
static void Main(string[] args) { MenuItemController dc = new MenuItemController(); while (true) { dc.UserInput(); } }
private void EachDirectionButton(MenuItemController directionButton, MenuItemController robotButton, RobotController robotController, string commandName) { bool isSpawn = commandName.Equals(Command.GetDisplay(Command.SPAWN_COMMAND_ID)); byte dir = (byte)Command.byteToDirectionString.ToString().IndexOf(directionButton.name); directionButton.SetSprite(isSpawn ? queueSprites[dir] : GetArrow(commandName)); directionButton.SetCallback(() => DirectionButtonCallback(robotButton, robotController, commandName, dir)); directionButton.spriteRenderer.transform.localRotation = Quaternion.Euler(Vector3.up * 180 + (isSpawn ? Vector3.zero : Vector3.forward * dir * 90)); directionButton.spriteRenderer.color = isSpawn ? Color.gray : Color.white; }
static void Main(string[] args) { Console.Clear(); MenuItemController mic = new MenuItemController(); while (true) { mic.GetInput(); } }
private void RobotButtonSelect(MenuItemController robotButton, RobotController robotController) { robotButtonContainer.SetButtons(true); ChangeLayer(selectedRobotController, boardLayer); robotButton.Select(); ChangeLayer(robotController, selectedLayer); selectedRobotController = robotController; robotController.ShowMenuOptions(commandButtonContainer); directionButtonContainer.SetButtons(false); directionButtonContainer.ClearSprites(); }
static void Main(string[] args) { Console.WriteLine("Welcome to the shack!"); MenuItemController _mc = new MenuItemController(); while (true) { _mc.UserInput(); } }
private void ConfigureMenuItem(GameObject instance, MenuItem template) { MenuItemController controller = instance.GetComponent <MenuItemController>(); if (!(controller is null)) { controller.SetIcon(template.itemIcon); controller.SetFilename(template.itemName); controller.SetFiletype(template.itemType); controller.nextScreen = template.screenPrefab; } }
public void Delete_Id_Is_Null() { // Arrange int?id = null; var mapper = Substitute.For <IMapper>(); var service = Substitute.For <IMenuItemRepository>(); var controller = new MenuItemController(service, mapper); // Act var result = controller.Delete(id) as HttpStatusCodeResult; var statusCode = result.StatusCode; // Assert Assert.That(result, !Is.Null); Assert.That(400, Is.EqualTo(statusCode)); }
private void btnUpdateSave_Click(object sender, EventArgs e) { String error = validateAllControls(); if (error == "") { data_models.Models.MenuItem m = new data_models.Models.MenuItem(); updateObjectFromForm(ref m); MenuItemController.UpdateItemByObject(_context, (int)activeID, m); loadMenuData(); showMenuList(); } else { MessageBox.Show(error, "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
internal void ShowMenuOptions(ButtonContainerController m) { if (!isSpawned && commands.Count == 0) { Command.TYPES.ToList().ForEach(t => m.GetByName(Command.GetDisplay(t)).SetActive(t == Command.SPAWN_COMMAND_ID)); } else { Command.TYPES.ToList().ForEach(t => { int num = GetNumCommandType(t); bool active = num < Command.limit[t] && !t.Equals(typeof(Command.Spawn)); MenuItemController item = m.GetByName(Command.GetDisplay(t)); item.SetActive(active); }); } }
public void CreatePartial() { // Arrange var service = Substitute.For <IMenuItemRepository>(); var mapper = Substitute.For <IMapper>(); var controller = new MenuItemController(service, mapper); // Act var result = controller.CreatePartial() as PartialViewResult; var viewName = result.ViewName; var model = result.Model; // Assert Assert.That(result, !Is.Null); Assert.That("_CreatePartial", Is.EqualTo(viewName)); Assert.That(model, Is.Null); }
public void Good_Post_Edit() { // Arrange var menuItem = new MenuItem() { ID = 1, Position = 1, Title = "Strona glowna", ActionName = "Index", ControllerName = "Home" }; var menuItemViewModel = new MenuItemViewModel() { ID = 1, Position = 1, Title = "Strona glowna", ActionName = "Index", ControllerName = "Home" }; var service = Substitute.For <IMenuItemRepository>(); var mapper = Substitute.For <IMapper>(); var validator = new ModelValidator <MenuItemViewModel>(menuItemViewModel); var fakeController = new FakeController(); var controller = new MenuItemController(service, mapper); fakeController.PrepareFakeAjaxRequest(); controller.ControllerContext = fakeController.GetControllerContext <MenuItemController>(new RouteData(), controller); service.Get(menuItem.ID).Returns(menuItem); mapper.Map <MenuItemViewModel, MenuItem>(menuItemViewModel).Returns(menuItem); service.Update(menuItem); service.Save(); // Act var valid = validator.IsValid(); validator.AddToModelError(controller); var result = controller.Edit(menuItemViewModel) as RedirectToRouteResult; var actionName = result.RouteValues.Values.ElementAt(0); var ajaxRequest = controller.Request.IsAjaxRequest(); // Assert Assert.That(result, !Is.Null); Assert.That("Index", Is.EqualTo(actionName)); Assert.That(ajaxRequest, Is.True); Assert.That(valid, Is.True); }
public void BindUiToRobotController(short robotId, RobotController robotController) { MenuItemController robotButton = Instantiate(genericButton, robotButtonContainer.transform); RobotPanelsContainerController container = robotController.isOpponent ? opponentsRobots : myRobots; robotButton.SetSprite(container.GetSprite(robotId)); robotButton.SetCallback(() => RobotButtonCallback(robotButton, robotController, robotId)); robotButton.gameObject.SetActive(!robotController.isOpponent); int teamLength = robotButtonContainer.menuItems.ToList().Count(m => m.gameObject.activeInHierarchy == !robotController.isOpponent); robotButton.transform.localPosition = Vector3.right * (teamLength % 4 * 3 - 4.5f); robotButtonContainer.menuItems = robotButtonContainer.menuItems.ToList().Concat(new List <MenuItemController>() { robotButton }).ToArray(); container.BindCommandClickCallback(robotController, CommandSlotClickCallback); }
public void Index() { // Arrange var menuItems = new List <MenuItem>() { new MenuItem() { Position = 1, Title = "Strona główna", ActionName = "Index", ControllerName = "Home" }, new MenuItem() { Position = 2, Title = "Menu", ActionName = "Pizza", ControllerName = "Menu" }, new MenuItem() { Position = 3, Title = "Galeria", ActionName = "Gallery", ControllerName = "Home" }, new MenuItem() { Position = 4, Title = "Kontakt", ActionName = "Contact", ControllerName = "Home" } }; var service = Substitute.For <IMenuItemRepository>(); var mapper = Substitute.For <IMapper>(); var controller = new MenuItemController(service, mapper); controller.TempData["ModelIsNotValid"] = "Fake content."; controller.ViewBag.ModelIsNotValid = controller.TempData["ModelIsNotValid"]; service.GetAll().Returns(menuItems); // Act var result = controller.Index() as ViewResult; var viewName = result.ViewName; var model = result.Model; var viewBag = controller.ViewBag.ModelIsNotValid; //Assert Assert.That(result, !Is.Null); Assert.That("Index", Is.EqualTo(viewName)); Assert.That(model, !Is.Null); Assert.That("Fake content.", Is.EqualTo(viewBag)); }
public void Get_Edit_Model_Is_Null() { // Arrange var id = 1; MenuItem menuItem = null; var service = Substitute.For <IMenuItemRepository>(); var mapper = Substitute.For <IMapper>(); var controller = new MenuItemController(service, mapper); service.Get(id).Returns(menuItem); // Act var result = controller.Edit(id) as HttpNotFoundResult; var statusCode = result.StatusCode; // Assert Assert.That(result, !Is.Null); Assert.That(404, Is.EqualTo(statusCode)); }
public void Good_Get_Edit() { // Arrange var id = 1; var menuItem = new MenuItem() { ID = 1, Position = 1, Title = "Strona główna", ActionName = "Index", ControllerName = "Home" }; var menuItemViewModel = new MenuItemViewModel() { ID = 1, Position = 1, Title = "Strona główna", ActionName = "Index", ControllerName = "Home" }; var service = Substitute.For <IMenuItemRepository>(); var mapper = Substitute.For <IMapper>(); var fakeController = new FakeController(); var controller = new MenuItemController(service, mapper); fakeController.PrepareFakeAjaxRequest(); controller.ControllerContext = fakeController.GetControllerContext <MenuItemController>(new RouteData(), controller); service.Get(id).Returns(menuItem); mapper.Map <MenuItem, MenuItemViewModel>(menuItem).Returns(menuItemViewModel); // Act var result = controller.Edit(id) as PartialViewResult; var viewName = result.ViewName; var model = result.Model; var ajaxRequest = controller.Request.IsAjaxRequest(); // Assert Assert.That(result, !Is.Null); Assert.That("_EditPartial", Is.EqualTo(viewName)); Assert.That(ajaxRequest, Is.True); Assert.That(model, !Is.Null); }
private static MenuItemController GetMenuItemController(BakeryContext bakeryContext, string requestHost = "localhost", string requestScheme = "http") { var menuItemController = new MenuItemController(bakeryContext); var mockRequest = new Mock <HttpRequest>(); mockRequest.Setup(m => m.Host).Returns(new HostString(requestHost)); mockRequest.Setup(m => m.Scheme).Returns(requestScheme); var mockHttpContext = new Mock <HttpContext>(); mockHttpContext.Setup(m => m.Request).Returns(mockRequest.Object); menuItemController.ControllerContext = new ControllerContext { HttpContext = mockHttpContext.Object }; return(menuItemController); }
public void loadMenu(List <string> listItems) { foreach (Transform child in ContentPanel.transform) { GameObject.Destroy(child.gameObject); } foreach (string itemString in listItems) { GameObject newListItem = Instantiate(ListItemPrefab) as GameObject; MenuItemController menuItemController = newListItem.GetComponent <MenuItemController>(); menuItemController.itemName = itemString; menuItemController.selector = menuItemSelector; menuItemSelector.selectedString = null; newListItem.transform.SetParent(ContentPanel.transform); newListItem.transform.localScale = Vector3.one; } }
public void Good_Post_Create() { // Arrange var menuItemViewModel = new MenuItemViewModel() { Position = 1, Title = "Strona glowna", ActionName = "Index", ControllerName = "Home" }; var menuItem = new MenuItem() { Position = 1, Title = "Strona glowna", ActionName = "Index", ControllerName = "Home" }; var validator = new ModelValidator <MenuItemViewModel>(menuItemViewModel); var service = Substitute.For <IMenuItemRepository>(); var mapper = Substitute.For <IMapper>(); var controller = new MenuItemController(service, mapper); mapper.Map <MenuItemViewModel, MenuItem>(menuItemViewModel).Returns(menuItem); service.Insert(menuItem); service.Save(); // Act var valid = validator.IsValid(); validator.AddToModelError(controller); var result = controller.Create(menuItemViewModel) as RedirectToRouteResult; var actionName = result.RouteValues.Values.ElementAt(0); // Assert Assert.That(result, !Is.Null); Assert.That("Index", Is.EqualTo(actionName)); Assert.That(valid, Is.True); }
// Handles creating the GameObject, then passes it over to the proper method for giving it it's correct values and what not public void createMenuItem(JSONNode jsonNode) { // Instantiate an instace of the Menu Item Prefab we want. (Based of the "_itemShape" value) // Set the position of this Menu Item at (0, -10f, 0) so its out of site (This can be adjusted) GameObject menuItem = (GameObject)Instantiate(menuItemPrefabContainer[jsonNode["_itemShape"]], new Vector3(0f, 1.3f, 0f), Quaternion.identity); // Give the item a unique tag for .... reasons menuItem.tag = "MenuItem"; // If there are a lot of similarities when assigning values and stuff to the prefab, put them here. No need for code duplication // Sets the name of the GameObject menuItem.name = jsonNode["_name"]; // If the menu item has no children, it's name could be repetitive, so we add the parent's name to it so there are no duplicates if (!jsonNode["_hasChildren"].AsBool) { menuItem.name += "-" + jsonNode["_parent"]; } // Passes data to the class that controls that menu item MenuItemController menuItemController = menuItem.GetComponent <MenuItemController>(); menuItemController.giveData(jsonNode, menuItem); }
/// <summary> /// 报告加载 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ReportView_Load(object sender, System.EventArgs e) { ReportViewModel reportViewModel = new ReportViewModel(this.context); Dictionary <string, object> paramDic = reportViewModel.GetParamDic(this.uiEvent, this.ent4BannerDTO); if (!paramDic.ContainsKey("funCode")) { BizAssMessageBoxUtil.ShowWarningMsg("加载报告时未获取到功能节点编码!"); return; } string funCode = paramDic["funCode"] as string; paramDic.Remove("funCode"); Control ctrl = XapEvents.GetFuncEvent(this, new GetFuncEventArgs(funCode, paramDic)); // XCefWebBrowser webBrower = ctrl as XCefWebBrowser; EmbedControl webBrower = ctrl as EmbedControl; string title = MenuItemController.GetInstance().FuncIdAndNameMapper[funCode]; StringBuilder msgBuilder = new StringBuilder(); string url = webBrower.Arguments; msgBuilder.Append("打开节点[" + title + "];节点编码:" + funCode + " ; 请求地址:" + url); string logMsg = LogManagerUtil.GetEnInfo(msgBuilder.ToString(), this.ent4BannerDTO); LogManager.GetLogger().InfoEx(logMsg); this.Text = title; ctrl.Dock = DockStyle.Fill; this.AddRender(ctrl); }
private void RemoveMenuItemController(MenuItemController menuItemControllerToDelete) { kebabMenu.RemoveMenuItem(menuItemControllerToDelete.menuItem); menuItemControls.Remove(menuItemControllerToDelete); Destroy(menuItemControllerToDelete.gameObject); UpdateAddMenuItemButtonInteractability(); }
public static MenuItemController Fixture() { MenuItemController controller = new MenuItemController(new MenuItemRepository(), "", new LoginView()); return(controller); }
public void ClearSelected() { selectedMenuItem = null; }
public void DeleteMenuItemController(MenuItemController menuItemController) { RemoveMenuItemController(menuItemController); }
private void DirectionButtonCallback(MenuItemController robotButton, RobotController robotController, string commandName, byte dir) { robotController.AddRobotCommand(commandName, dir, AddSubmittedCommand); RobotButtonSelect(robotButton, robotController); commandButtonContainer.ClearSelected(); }
public static MenuItemController Fixture() { MenuItemController controller = new MenuItemController(new MenuItemRepository()); return controller; }