public void ExecuteTest() { //po referencjach do kolumn List <Column> originalColumns = new List <Column>(); var column1 = new Mock <Column>(); var column2 = new Mock <Column>(); var column3 = new Mock <Column>(); originalColumns.Add(column1.Object); originalColumns.Add(column2.Object); originalColumns.Add(column3.Object); List <Column> selectedColumns = new List <Column>(); selectedColumns.Add(column1.Object); selectedColumns.Add(column3.Object); SelectCommand target = new SelectCommand(selectedColumns); var table = new Mock <Table>(); //tabela oryginalna var table2 = new Mock <Table>(); //tabela, która powinna powstać table.Setup(foo => foo.Columns).Returns(originalColumns); table2.Setup(foo => foo.Columns).Returns(selectedColumns); List <Column> receivedColumns = target.Execute(table.Object).Columns; CollectionAssert.AreEqual(table2.Object.Columns, receivedColumns); //po indeksach List <int> selectedIndeces = new List <int>(); selectedIndeces.Add(0); selectedIndeces.Add(2); target = new SelectCommand(selectedIndeces); receivedColumns = target.Execute(table.Object).Columns; CollectionAssert.AreEqual(table2.Object.Columns, receivedColumns); }
public void DoCommand(Command command) { switch (command.type) { case CommandType.DESCRIBE: DescribeCommand describeCommand = (DescribeCommand)command; describeCommand.Execute(mapController, describeCommand.id != null ? FindEntity(describeCommand.id) : null); break; case CommandType.SELECT: SelectCommand selectCommand = (SelectCommand)command; selectCommand.Execute(mapController, GetPlayerById(selectCommand.playerId)); break; case CommandType.PERFORMACTION: PerformActionCommand performActionCommand = (PerformActionCommand)command; performActionCommand.Execute(mapController, GetPlayerById(performActionCommand.playerId), GetPlayerById(performActionCommand.playerId).selectedEntity); break; case CommandType.ENDTURN: EndTurnCommand endTurnCommand = (EndTurnCommand)command; endTurnCommand.Execute(turnController); break; default: break; } }
public void SelectRegions() { var regions = canvas.SelectedRooms.Select(p => p.Region).Distinct().ToList(); var cmd = new SelectCommand(); cmd.Execute(canvas, SelectTypes.Region, regions); }
private void SelectItem(object currentItem) { if (DisplayMemberPath != String.Empty) { var propInfo = currentItem.GetType().GetProperties(). Where(p => p.Name == DisplayMemberPath).FirstOrDefault(); if (propInfo != null) { Text = propInfo.GetValue(currentItem, null).ToString(); } else { Text = currentItem.ToString(); } } else { Text = currentItem.ToString(); } SelectAll(); SelectCommand.Execute(currentItem); popup.IsOpen = false; }
public void TestSelect_WithUnexistentCore_ShouldReturnErrorMessage() { ICommand testCommand = new SelectCommand(this.testNuclearPowerPlant, "A"); String actualMessage = testCommand.Execute(); String expectedMessage = "Failed to select Core A!"; Assert.AreEqual(expectedMessage, actualMessage, "Select command does not work correctly!"); }
protected override void OnPointerReleased(PointerReleasedEventArgs e) { e.Handled = true; if (isPressed) { RoutedEventArgs args = new RoutedEventArgs(ClickEvent); RaiseEvent(args); SelectCommand.Execute(this); } IsPressed = isPressed = false; base.OnPointerReleased(e); }
public void TestSelect_WithExistentCore_ShouldReturnSuccessMessage() { ICore dummyCore = new SystemCore("A", 20); this.testNuclearPowerPlant.AttachCore(dummyCore); ICommand testCommand = new SelectCommand(this.testNuclearPowerPlant, "A"); String actualMessage = testCommand.Execute(); String expectedMessage = "Currently selected Core A!"; Assert.AreEqual(expectedMessage, actualMessage, "Select command does not work correctly!"); }
public void TestSelect_WithExistentCore_ShouldSetCurrentlySelectedCoreCorrectly() { ICore dummyCore = new SystemCore("A", 20); this.testNuclearPowerPlant.AttachCore(dummyCore); ICommand testCommand = new SelectCommand(this.testNuclearPowerPlant, "A"); testCommand.Execute(); Assert.AreEqual( this.testNuclearPowerPlant.CurrentlySelectedCore, dummyCore, "Select command does not work correctly!"); }
private void SelectElement(object o) { if ((o == null)) { return; } var EnumerableObjects = from object p in CompleteCollection select p; Selected = EnumerableObjects.Where(x => x.ToString() == o.ToString()).FirstOrDefault(); FocusButton(); if ((SelectCommand != null)) { SelectCommand.Execute(Selected); } }
private Task OnItemTapped(object item) { TapCommand?.Execute(item); string path = SelectionPath; if (path == null) { return(Task.CompletedTask); } ; object data = null; VisualElement ve = item as VisualElement; if (ve != null) { data = ve.BindingContext; } else { data = item; } if (data == null) { return(Task.CompletedTask); } var isSelected = (bool)data.GetPropertyValue(path); data.SetPropertyValue(path, !isSelected); if (!isSelected) { SelectCommand?.Execute(data); } else { DeselectCommand?.Execute(data); } return(Task.CompletedTask); }
private void OnEntrySelected(object sender, SelectedItemChangedEventArgs e) { if (SelectCommand == null) { return; } var entry = e.SelectedItem; if (SelectCommand.CanExecute(entry)) { SelectCommand.Execute(entry); } var masterDetailPage = _pageProvider.GetMasterDetailPage(); masterDetailPage.IsPresented = false; }
public void ParseAndExecuteSelectCommandWithFields() { SelectCommand cmd = (SelectCommand)GetCommand("select LastName, FirstName from Employees"); cmd.Execute(this.database); var result = cmd.Result; Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(RowList)); RowList list = (RowList)result; Assert.AreEqual(3, list.Count); Assert.AreEqual("John", list[0]["FirstName"]); Assert.AreEqual("Smith", list[0]["LastName"]); Row row = list[0]; Assert.AreEqual(2, row.ColumnCount); Assert.AreEqual("LastName", row.GetColumn(0).Name); Assert.AreEqual("FirstName", row.GetColumn(1).Name); }
protected override void MouseDoubleClickCommand_OnExecute() { SelectCommand.Execute(null); }
public void Select(SelectTypes type) { var cmd = new SelectCommand(); cmd.Execute(canvas, type); }
public void TestExecuteShouldSetSelectedRows() { _command.Execute(_items); _mockMessageBus.Verify(p => p.Execute( It.Is <SetSelectedRowsCommand>(q => q.Rows.Single() == _row)), Times.Once()); }