public void GivenDialogWithSelectedItems_WhenCancelButtonClicked_ThenReturnsEmptyCollection() { // Given var selectedItem = new object(); object[] items = { selectedItem, new object() }; using (var dialog = new TestFullyConfiguredSelectionDialogBase(testForm)) { dialog.SetDataSource(items); dialog.Show(); var selectionView = (DataGridViewControl) new ControlTester("DataGridViewControl", dialog).TheObject; selectionView.Rows[0].Cells[0].Value = true; // When var cancelButton = new ButtonTester("CustomCancelButton", dialog); cancelButton.Click(); // Then CollectionAssert.IsEmpty(dialog.SelectedItems); } }
public void DoForSelectedButton_NoneSelected_DoForSelectedButtonDisabled() { // Setup var items = new[] { new object(), new object() }; using (var dialog = new TestFullyConfiguredSelectionDialogBase(testForm)) { dialog.SetDataSource(items); dialog.Show(); var buttonTester = new ButtonTester("DoForSelectedButton", dialog); // Call var button = (Button)buttonTester.TheObject; // Assert Assert.IsFalse(button.Enabled); CollectionAssert.IsEmpty(dialog.SelectedItems); } }
public void GivenDialogWithSelectedItems_WhenCloseWithoutConfirmation_ThenReturnsEmptyCollection() { // Given var items = new[] { new object(), new object() }; using (var dialog = new TestFullyConfiguredSelectionDialogBase(testForm)) { dialog.SetDataSource(items); dialog.Show(); var selectionView = (DataGridViewControl) new ControlTester("DataGridViewControl", dialog).TheObject; selectionView.Rows[0].Cells[0].Value = true; // When dialog.Close(); // Then CollectionAssert.IsEmpty(dialog.SelectedItems); } }