コード例 #1
0
        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);
        }
コード例 #2
0
        private TestDuneLocationCalculationsView ShowTestCalculatableView()
        {
            var view = new TestDuneLocationCalculationsView();

            testForm.Controls.Add(view);
            testForm.Show();
            return(view);
        }
コード例 #3
0
        public void Constructor_CalculateAllButtonCorrectlyInitialized()
        {
            // Setup & Call
            TestDuneLocationCalculationsView view = ShowTestCalculatableView();

            // Assert
            var button = (Button)view.Controls.Find("CalculateForSelectedButton", true)[0];

            Assert.IsFalse(button.Enabled);
        }
コード例 #4
0
        private TestDuneLocationCalculationsView ShowFullyConfiguredTestCalculatableView()
        {
            TestDuneLocationCalculationsView view = ShowTestCalculatableView();

            view.Data = new[]
            {
                new TestCalculatableObject(),
                new TestCalculatableObject()
            };
            return(view);
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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));
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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());
        }
コード例 #11
0
        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);
        }