public void Selection_Always_ReturnsTheSelectedRowObject(int selectedRow) { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); ConfigureHydraulicBoundaryDatabase(assessmentSection); mocks.ReplayAll(); ClosingStructuresFailureMechanism failureMechanism = ConfigureFailureMechanism(); CalculationGroup calculationGroup = ConfigureCalculationGroup(failureMechanism, assessmentSection); ClosingStructuresCalculationsView 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 <ClosingStructuresInputContext>(selection); var dataRow = (ClosingStructuresCalculationRow)dataGridView.Rows[selectedRow].DataBoundItem; Assert.AreSame(dataRow.Calculation, ((ClosingStructuresInputContext)selection).Calculation); mocks.VerifyAll(); }
public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue() { // Setup var failureMechanism = new ClosingStructuresFailureMechanism(); 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 ClosingStructuresCalculationsView(failureMechanism.CalculationsGroup, failureMechanism, assessmentSection)) { // Call bool closeForData = info.CloseForData(view, assessmentSection); // Assert Assert.IsTrue(closeForData); } mocks.VerifyAll(); }
private ClosingStructuresCalculationsView ShowCalculationsView(CalculationGroup calculationGroup, ClosingStructuresFailureMechanism failureMechanism, IAssessmentSection assessmentSection) { var calculationsView = new ClosingStructuresCalculationsView(calculationGroup, failureMechanism, assessmentSection); testForm.Controls.Add(calculationsView); testForm.Show(); return(calculationsView); }
public void Constructor_ExpectedValues() { // Call ClosingStructuresCalculationsView view = ShowCalculationsView(new CalculationGroup(), new ClosingStructuresFailureMechanism(), new AssessmentSectionStub()); // Assert Assert.IsInstanceOf <CalculationsView <StructuresCalculationScenario <ClosingStructuresInput>, ClosingStructuresInput, ClosingStructuresCalculationRow, ClosingStructuresFailureMechanism> >(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 ClosingStructuresCalculationsView(new CalculationGroup(), new ClosingStructuresFailureMechanism(), assessmentSection)) { // Call bool closeForData = info.CloseForData(view, assessmentSection); // Assert Assert.IsFalse(closeForData); } }
public void CloseForData_ViewCorrespondingToRemovedCalculationsContext_ReturnsTrue() { // Setup var assessmentSection = new AssessmentSectionStub(); var failureMechanism = new ClosingStructuresFailureMechanism(); using (var view = new ClosingStructuresCalculationsView(failureMechanism.CalculationsGroup, new ClosingStructuresFailureMechanism(), assessmentSection)) { var context = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSection); // Call bool closeForData = info.CloseForData(view, context); // Assert Assert.IsTrue(closeForData); } }
private static bool CloseCalculationsViewForData(ClosingStructuresCalculationsView view, object dataToCloseFor) { ClosingStructuresFailureMechanism failureMechanism = null; if (dataToCloseFor is CalculationsStateFailureMechanismContext failureMechanismContext) { failureMechanism = failureMechanismContext.WrappedData; } if (dataToCloseFor is IAssessmentSection assessmentSection) { failureMechanism = assessmentSection.GetFailureMechanisms() .OfType <ClosingStructuresFailureMechanism>() .FirstOrDefault(); } return(failureMechanism != null && ReferenceEquals(view.Data, failureMechanism.CalculationsGroup)); }