public void Update_WithValidProfile_UpdatesProperties(MacroStabilityInwardsStochasticSoilProfile stochasticProfile, MacroStabilityInwardsStochasticSoilProfile otherStochasticProfile) { // Call stochasticProfile.Update(otherStochasticProfile); // Assert Assert.AreEqual(otherStochasticProfile.Probability, stochasticProfile.Probability); Assert.AreSame(otherStochasticProfile.SoilProfile, stochasticProfile.SoilProfile); }
public void Update_WithNullProfile_ThrowsArgumentNullException() { // Setup var mocks = new MockRepository(); var soilProfile = mocks.Stub <IMacroStabilityInwardsSoilProfile <IMacroStabilityInwardsSoilLayer> >(); mocks.ReplayAll(); var stochasticProfile = new MacroStabilityInwardsStochasticSoilProfile(0.0, soilProfile); // Call void Call() => stochasticProfile.Update(null); // Assert string paramName = Assert.Throws <ArgumentNullException>(Call).ParamName; Assert.AreEqual("fromProfile", paramName); mocks.VerifyAll(); }
public void GivenCalculationsViewWithStochasticSoilProfile_WhenProbabilityChangesAndNotified_ThenNewProbabilityVisible() { // Given var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); ConfigureHydraulicBoundaryDatabase(assessmentSection); mocks.ReplayAll(); MacroStabilityInwardsFailureMechanism failureMechanism = ConfigureFailureMechanism(); CalculationGroup calculationGroup = ConfigureCalculationGroup(assessmentSection, failureMechanism); ShowMacroStabilityInwardsCalculationsView(calculationGroup, failureMechanism, assessmentSection); var calculation = (MacroStabilityInwardsCalculationScenario)calculationGroup.Children[1]; var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; var refreshed = 0; // Precondition var currentCell = (DataGridViewTextBoxCell)dataGridView.Rows[1].Cells[stochasticSoilProfilesProbabilityColumnIndex]; Assert.AreEqual(GetFormattedProbabilityValue(30), currentCell.FormattedValue); MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfileToChange = calculation.InputParameters.StochasticSoilProfile; var updatedProfile = new MacroStabilityInwardsStochasticSoilProfile(0.5, stochasticSoilProfileToChange.SoilProfile); dataGridView.Invalidated += (sender, args) => refreshed++; // When stochasticSoilProfileToChange.Update(updatedProfile); stochasticSoilProfileToChange.NotifyObservers(); // Then Assert.AreEqual(1, refreshed); var cell = (DataGridViewTextBoxCell)dataGridView.Rows[1].Cells[stochasticSoilProfilesProbabilityColumnIndex]; Assert.AreEqual(GetFormattedProbabilityValue(50), cell.FormattedValue); mocks.VerifyAll(); }