public void DeselectAllButton_AllCalculatableItemsSelectedDeselectAllButtonClicked_AllCalculatableItemsNotSelected() { // Setup TestDuneLocationCalculationsView view = ShowFullyConfiguredTestCalculatableView(); var dataGridView = (DataGridView)view.Controls.Find("dataGridView", true)[0]; var button = new ButtonTester("DeselectAllButton", testForm); DataGridViewRowCollection rows = dataGridView.Rows; foreach (DataGridViewRow row in rows) { row.Cells[calculateColumnIndex].Value = true; } // Precondition Assert.IsTrue((bool)rows[0].Cells[calculateColumnIndex].Value); Assert.IsTrue((bool)rows[1].Cells[calculateColumnIndex].Value); // Call button.Click(); // Assert Assert.IsFalse((bool)rows[0].Cells[calculateColumnIndex].Value); Assert.IsFalse((bool)rows[1].Cells[calculateColumnIndex].Value); }
private TestDuneLocationCalculationsView ShowTestCalculatableView() { var view = new TestDuneLocationCalculationsView(); testForm.Controls.Add(view); testForm.Show(); return(view); }
public void Constructor_CalculateAllButtonCorrectlyInitialized() { // Setup & Call TestDuneLocationCalculationsView view = ShowTestCalculatableView(); // Assert var button = (Button)view.Controls.Find("CalculateForSelectedButton", true)[0]; Assert.IsFalse(button.Enabled); }
private TestDuneLocationCalculationsView ShowFullyConfiguredTestCalculatableView() { TestDuneLocationCalculationsView view = ShowTestCalculatableView(); view.Data = new[] { new TestCalculatableObject(), new TestCalculatableObject() }; return(view); }
public void DefaultConstructor_DefaultValues() { // Call using (var view = new TestDuneLocationCalculationsView()) { // Assert Assert.IsInstanceOf <UserControl>(view); Assert.IsInstanceOf <ISelectionProvider>(view); Assert.IsNull(view.Data); Assert.AreEqual(new Size(526, 85), view.AutoScrollMinSize); } }
public void GivenFullyConfiguredView_WhenNoRowsSelected_ThenCalculateForSelectedButtonDisabledAndErrorMessageProvided() { // Given & When TestDuneLocationCalculationsView view = ShowFullyConfiguredTestCalculatableView(); // Then var button = (Button)view.Controls.Find("CalculateForSelectedButton", true)[0]; Assert.IsFalse(button.Enabled); var errorProvider = TypeUtils.GetField <ErrorProvider>(view, "CalculateForSelectedButtonErrorProvider"); Assert.AreEqual("Er zijn geen berekeningen geselecteerd.", errorProvider.GetError(button)); }
public void Selection_Always_ReturnsCreatedSelectionObject() { // Setup TestDuneLocationCalculationsView view = ShowFullyConfiguredTestCalculatableView(); var createdSelection = new object(); view.CreateForSelection = createdSelection; // Call object selection = view.Selection; // Assert Assert.AreSame(createdSelection, selection); }
public void GivenFullyConfiguredView_WhenRowsSelected_ThenCalculateForSelectedButtonEnabledAndNoErrorMessageProvided() { // Given TestDuneLocationCalculationsView view = ShowFullyConfiguredTestCalculatableView(); var dataGridView = (DataGridView)view.Controls.Find("dataGridView", true)[0]; // When dataGridView.Rows[0].Cells[calculateColumnIndex].Value = true; // Then var button = (Button)view.Controls.Find("CalculateForSelectedButton", true)[0]; Assert.IsTrue(button.Enabled); var errorProvider = TypeUtils.GetField <ErrorProvider>(view, "CalculateForSelectedButtonErrorProvider"); Assert.AreEqual("", errorProvider.GetError(button)); }
public void OnLoad_DataGridViewCorrectlyInitialized() { // Setup & Call TestDuneLocationCalculationsView view = ShowTestCalculatableView(); // Assert var dataGridView = (DataGridView)view.Controls.Find("dataGridView", true)[0]; Assert.AreEqual(1, dataGridView.ColumnCount); var calculateColumn = (DataGridViewCheckBoxColumn)dataGridView.Columns[calculateColumnIndex]; const string expectedCalculateHeaderText = "Berekenen"; Assert.AreEqual(expectedCalculateHeaderText, calculateColumn.HeaderText); var button = (Button)view.Controls.Find("CalculateForSelectedButton", true)[0]; Assert.IsFalse(button.Enabled); }
public void CalculateForSelectedButton_OneSelected_CallsCalculateHandleCalculateSelectedObjects() { // Setup TestDuneLocationCalculationsView view = ShowFullyConfiguredTestCalculatableView(); var dataGridView = (DataGridView)view.Controls.Find("dataGridView", true)[0]; DataGridViewRowCollection rows = dataGridView.Rows; rows[0].Cells[calculateColumnIndex].Value = true; var buttonTester = new ButtonTester("CalculateForSelectedButton", testForm); // Call buttonTester.Click(); // Assert Assert.AreEqual(1, view.ObjectsToCalculate.Count()); TestCalculatableObject expectedObject = ((IEnumerable <TestCalculatableObject>)view.Data).First(); Assert.AreEqual(expectedObject, view.ObjectsToCalculate.First()); }
public void GivenFullyConfiguredView_WhenSelectingCellInRow_ThenSelectionChangedFired() { // Given TestDuneLocationCalculationsView view = ShowFullyConfiguredTestCalculatableView(); var createdSelection = new object(); view.CreateForSelection = createdSelection; var selectionChangedCount = 0; view.SelectionChanged += (sender, args) => selectionChangedCount++; var dataGridView = (DataGridView)view.Controls.Find("dataGridView", true)[0]; // When dataGridView.CurrentCell = dataGridView.Rows[1].Cells[calculateColumnIndex]; EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(0, 0)); // Then Assert.AreEqual(1, selectionChangedCount); }