Esempio n. 1
0
        public void Selection_Always_ReturnsTheSelectedRowObject(int selectedRow)
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            ConfigureHydraulicBoundaryDatabase(assessmentSection);
            mocks.ReplayAll();

            HeightStructuresFailureMechanism failureMechanism = ConfigureFailureMechanism();
            CalculationGroup calculationGroup = ConfigureCalculationGroup(failureMechanism, assessmentSection);

            HeightStructuresCalculationsView view = ShowCalculationsView(calculationGroup, failureMechanism, assessmentSection);

            var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;

            dataGridView.CurrentCell = dataGridView.Rows[selectedRow].Cells[0];

            // Call
            object selection = view.Selection;

            // Assert
            Assert.IsInstanceOf <HeightStructuresInputContext>(selection);
            var dataRow = (HeightStructuresCalculationRow)dataGridView.Rows[selectedRow].DataBoundItem;

            Assert.AreSame(dataRow.Calculation, ((HeightStructuresInputContext)selection).Calculation);
            mocks.VerifyAll();
        }
        public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue()
        {
            // Setup
            var failureMechanism  = new HeightStructuresFailureMechanism();
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            assessmentSection.Stub(asm => asm.GetFailureMechanisms()).Return(new IFailureMechanism[]
            {
                failureMechanism
            });
            assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(new HydraulicBoundaryDatabase
            {
                Locations =
                {
                    new HydraulicBoundaryLocation(1, "Location 1", 1.1, 2.2),
                    new HydraulicBoundaryLocation(2, "Location 2", 3.3, 4.4)
                }
            });
            mocks.ReplayAll();

            using (var view = new HeightStructuresCalculationsView(failureMechanism.CalculationsGroup, failureMechanism, assessmentSection))
            {
                // Call
                bool closeForData = info.CloseForData(view, assessmentSection);

                // Assert
                Assert.IsTrue(closeForData);
            }

            mocks.VerifyAll();
        }
Esempio n. 3
0
        private HeightStructuresCalculationsView ShowCalculationsView(CalculationGroup calculationGroup, HeightStructuresFailureMechanism failureMechanism, IAssessmentSection assessmentSection)
        {
            var calculationsView = new HeightStructuresCalculationsView(calculationGroup, failureMechanism, assessmentSection);

            testForm.Controls.Add(calculationsView);
            testForm.Show();

            return(calculationsView);
        }
Esempio n. 4
0
        public void Constructor_ExpectedValues()
        {
            // Call
            HeightStructuresCalculationsView view = ShowCalculationsView(new CalculationGroup(), new HeightStructuresFailureMechanism(), new AssessmentSectionStub());

            // Assert
            Assert.IsInstanceOf <CalculationsView <StructuresCalculationScenario <HeightStructuresInput>, HeightStructuresInput, HeightStructuresCalculationRow, HeightStructuresFailureMechanism> >(view);

            var button = (Button) new ControlTester("generateButton").TheObject;

            Assert.AreEqual("Genereer &berekeningen...", button.Text);
        }
        public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();

            using (var view = new HeightStructuresCalculationsView(new CalculationGroup(), new HeightStructuresFailureMechanism(), assessmentSection))
            {
                bool closeForData = info.CloseForData(view, assessmentSection);

                // Assert
                Assert.IsFalse(closeForData);
            }
        }
        public void CloseForData_ViewCorrespondingToRemovedCalculationsContext_ReturnsTrue()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();
            var failureMechanism  = new HeightStructuresFailureMechanism();

            using (var view = new HeightStructuresCalculationsView(failureMechanism.CalculationsGroup, failureMechanism, assessmentSection))
            {
                var context = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection);

                // Call
                bool closeForData = info.CloseForData(view, context);

                // Assert
                Assert.IsTrue(closeForData);
            }
        }
Esempio n. 7
0
        private static bool CloseCalculationsViewForData(HeightStructuresCalculationsView view, object dataToCloseFor)
        {
            HeightStructuresFailureMechanism failureMechanism = null;

            if (dataToCloseFor is IAssessmentSection assessmentSection)
            {
                failureMechanism = assessmentSection.GetFailureMechanisms()
                                   .OfType <HeightStructuresFailureMechanism>()
                                   .FirstOrDefault();
            }

            if (dataToCloseFor is CalculationsStateFailureMechanismContext failureMechanismContext)
            {
                failureMechanism = failureMechanismContext.WrappedData;
            }

            return(failureMechanism != null && ReferenceEquals(view.Data, failureMechanism.CalculationsGroup));
        }