public void Selection_Always_ReturnsTheSelectedRowObject(int selectedRow) { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); ConfigureHydraulicBoundaryDatabase(assessmentSection); mocks.ReplayAll(); StabilityPointStructuresFailureMechanism failureMechanism = ConfigureFailureMechanism(); CalculationGroup calculationGroup = ConfigureCalculationGroup(failureMechanism, assessmentSection); StabilityPointStructuresCalculationsView 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 <StabilityPointStructuresInputContext>(selection); var dataRow = (StabilityPointStructuresCalculationRow)dataGridView.Rows[selectedRow].DataBoundItem; Assert.AreSame(dataRow.Calculation, ((StabilityPointStructuresInputContext)selection).Calculation); mocks.VerifyAll(); }
public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue() { // Setup var failureMechanism = new StabilityPointStructuresFailureMechanism(); 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 StabilityPointStructuresCalculationsView(failureMechanism.CalculationsGroup, failureMechanism, assessmentSection)) { // Call bool closeForData = info.CloseForData(view, assessmentSection); // Assert Assert.IsTrue(closeForData); } mocks.VerifyAll(); }
private StabilityPointStructuresCalculationsView ShowCalculationsView(CalculationGroup calculationGroup, StabilityPointStructuresFailureMechanism failureMechanism, IAssessmentSection assessmentSection) { var calculationsView = new StabilityPointStructuresCalculationsView(calculationGroup, failureMechanism, assessmentSection); testForm.Controls.Add(calculationsView); testForm.Show(); return(calculationsView); }
public void CalculationsView_EditingPropertyViaDataGridView_ObserversCorrectlyNotified( int cellIndex, object newValue, bool useCalculationWithOutput) { // Setup var mocks = new MockRepository(); var calculationObserver = mocks.StrictMock <IObserver>(); var inputObserver = mocks.StrictMock <IObserver>(); if (useCalculationWithOutput) { DialogBoxHandler = (name, wnd) => { var tester = new MessageBoxTester(wnd); tester.ClickOk(); }; calculationObserver.Expect(o => o.UpdateObserver()); } inputObserver.Expect(o => o.UpdateObserver()); var assessmentSection = mocks.Stub <IAssessmentSection>(); ConfigureHydraulicBoundaryDatabase(assessmentSection); assessmentSection.Stub(a => a.Attach(null)).IgnoreArguments(); assessmentSection.Stub(a => a.Detach(null)).IgnoreArguments(); assessmentSection.Replay(); StabilityPointStructuresFailureMechanism failureMechanism = ConfigureFailureMechanism(); StabilityPointStructuresCalculationsView calculationsView = ShowCalculationsView(ConfigureCalculationGroup(failureMechanism, assessmentSection), failureMechanism, assessmentSection); mocks.ReplayAll(); var data = (CalculationGroup)calculationsView.Data; var calculationScenario = (StructuresCalculationScenario <StabilityPointStructuresInput>)data.Children[1]; if (useCalculationWithOutput) { calculationScenario.Output = new TestStructuresOutput(); } calculationScenario.Attach(calculationObserver); calculationScenario.InputParameters.Attach(inputObserver); var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; // Call dataGridView.Rows[1].Cells[cellIndex].Value = newValue is double value ? (RoundedDouble)value : newValue; // Assert calculationScenario.Output = null; mocks.VerifyAll(); }
public void Constructor_ExpectedValues() { // Call StabilityPointStructuresCalculationsView view = ShowCalculationsView(new CalculationGroup(), new StabilityPointStructuresFailureMechanism(), new AssessmentSectionStub()); // Assert Assert.IsInstanceOf <CalculationsView <StructuresCalculationScenario <StabilityPointStructuresInput>, StabilityPointStructuresInput, StabilityPointStructuresCalculationRow, StabilityPointStructuresFailureMechanism> >(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 StabilityPointStructuresCalculationsView(new CalculationGroup(), new StabilityPointStructuresFailureMechanism(), 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 StabilityPointStructuresFailureMechanism(); using (var view = new StabilityPointStructuresCalculationsView(failureMechanism.CalculationsGroup, failureMechanism, assessmentSection)) { var context = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection); // Call bool closeForData = info.CloseForData(view, context); // Assert Assert.IsTrue(closeForData); } }