public void initializeCockpitConfigurationTest() { DisplayConfigurationManager displayManager = new DisplayConfigurationManager(); List<Gadget> gadgets = new List<Gadget>(); Gadget gadget = new Gadget(1, "gadget1", position: 0); gadgets.Add(gadget); gadget = new Gadget(2, "gadget2", position: 0); gadgets.Add(gadget); gadget = new Gadget(3, "gadget3", position: 0); gadgets.Add(gadget); gadget = new Gadget(4, "gadget4", position: 1); gadgets.Add(gadget); gadget = new Gadget(5, "gadget5", position: 1); gadgets.Add(gadget); gadget = new Gadget(6, "gadget6", position: 1); gadgets.Add(gadget); cockpitConfiguration = new CockpitConfiguration(33, gadgets, displayManager.getDisplayWithId(1)); TestContext.RequestedPage.Session.Add("currentCockpitConfiguration", cockpitConfiguration); }
public void setGadget(Gadget gadget) { this.gadget = gadget; }
public void updateGadgetPositionTest() { int originColumnId = 0; // TODO: Initialize to an appropriate value int originRowId = 0; // TODO: Initialize to an appropriate value int destinationColumnId = 0; // TODO: Initialize to an appropriate value int destinationRowId = 0; // TODO: Initialize to an appropriate value CockpitConfiguration cockpitConfigurationToObtain; //***************************************************************** DisplayConfigurationManager displayManager = new DisplayConfigurationManager(); List<Gadget> gadgets = new List<Gadget>(); Gadget gadget = new Gadget(1, "gadget1", position: 0); gadgets.Add(gadget); gadget = new Gadget(2, "gadget2", position: 0); gadgets.Add(gadget); gadget = new Gadget(3, "gadget3", position: 0); gadgets.Add(gadget); gadget = new Gadget(4, "gadget4", position: 1); gadgets.Add(gadget); gadget = new Gadget(5, "gadget5", position: 1); gadgets.Add(gadget); gadget = new Gadget(6, "gadget6", position: 1); gadgets.Add(gadget); cockpitConfigurationToObtain = new CockpitConfiguration(23, gadgets, displayManager.getDisplayWithId(1)); //************************************************************************************** cockpitConfiguration = EditCockpit.updateGadgetPosition(originColumnId, originRowId, destinationColumnId, destinationRowId); TestContext.RequestedPage.Session.Add("currentCockpitConfiguration", cockpitConfiguration); compareCockpitConfigurations(cockpitConfigurationToObtain); //move gadget 5 on second position first column gadgets = new List<Gadget>(); gadget = new Gadget(1, "gadget1", position: 0); gadgets.Add(gadget); gadget = new Gadget(5, "gadget5", position: 0); gadgets.Add(gadget); gadget = new Gadget(2, "gadget2", position: 0); gadgets.Add(gadget); gadget = new Gadget(3, "gadget3", position: 0); gadgets.Add(gadget); gadget = new Gadget(4, "gadget4", position: 1); gadgets.Add(gadget); gadget = new Gadget(6, "gadget6", position: 1); gadgets.Add(gadget); cockpitConfigurationToObtain = new CockpitConfiguration(12, gadgets, displayManager.getDisplayWithId(1)); cockpitConfiguration = EditCockpit.updateGadgetPosition(2, 2, 1, 1); compareCockpitConfigurations(cockpitConfigurationToObtain, isGadgetsPositionTrue: false); //*********************************************************************************************** gadgets = new List<Gadget>(); gadget = new Gadget(5, "gadget5", position: 0); gadgets.Add(gadget); gadget = new Gadget(1, "gadget1", position: 0); gadgets.Add(gadget); gadget = new Gadget(2, "gadget2", position: 0); gadgets.Add(gadget); gadget = new Gadget(3, "gadget3", position: 0); gadgets.Add(gadget); gadget = new Gadget(4, "gadget4", position: 1); gadgets.Add(gadget); gadget = new Gadget(6, "gadget6", position: 1); gadgets.Add(gadget); cockpitConfigurationToObtain = new CockpitConfiguration(11, gadgets, displayManager.getDisplayWithId(1)); compareCockpitConfigurations(cockpitConfigurationToObtain, isGadgetsPositionTrue: true); }
private void setupGadgetPanel(Panel targetContainer, Gadget gadget) { Panel gadgetPanel = new Panel(); gadgetPanel.ID = "gadgetPanel" + gadget.getGadgetId().ToString(); Table gadgetTable = new Table(); TableRow row = new TableRow(); TableCell nameCell = new TableCell(); nameCell.Width = Unit.Percentage(15); TableCell imageCell = new TableCell(); imageCell.Width = Unit.Percentage(30); TableCell descriptionCell = new TableCell(); descriptionCell.Width = Unit.Percentage(45); TableCell buttonCell = new TableCell(); buttonCell.Width = Unit.Percentage(10); Label gadgetName = new Label(); gadgetName.ID = "gadgetName" + gadget.getGadgetId().ToString(); gadgetName.Text = gadget.getName(); nameCell.Controls.Add(gadgetName); Image gadgetImage = new Image(); gadgetImage.ImageUrl = "Images/gadgetsImages/" + gadget.getImage(); imageCell.Controls.Add(gadgetImage); Label gadgetDescription = new Label(); gadgetDescription.ID = "gadgetDescription" + gadget.getGadgetId().ToString(); gadgetDescription.Text = gadget.getDescription(); descriptionCell.Controls.Add(gadgetDescription); Button addButton = new Button(); addButton.Attributes.Add("OnClick", "return stockGadgetId(" + gadget.getGadgetId() + ");"); addButton.ID = "btnAddGadget" + gadget.getGadgetId().ToString(); addButton.CommandName = "addThisGadget"; addButton.CommandArgument = gadget.getGadgetId().ToString(); addButton.CssClass = "openDialogClass"; addButton.Text = "Add"; buttonCell.Controls.Add(addButton); row.Cells.Add(nameCell); row.Cells.Add(imageCell); row.Cells.Add(descriptionCell); row.Cells.Add(buttonCell); gadgetTable.Rows.Add(row); gadgetPanel.Controls.Add(gadgetTable); targetContainer.Controls.Add(gadgetPanel); }