public void CreateHydraulicBoundaryLocationCalculationsObserver_CalculationsNull_ThrowsArgumentNullException() { // Call TestDelegate call = () => ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver(null, () => {}); // Assert var exception = Assert.Throws <ArgumentNullException>(call); Assert.AreEqual("calculations", exception.ParamName); }
private void CreateObservers() { failureMechanismContributionObserver = new Observer(UpdateFeatures) { Observable = assessmentSection.FailureMechanismContribution }; hydraulicBoundaryLocationsObserver = new Observer(UpdateFeatures) { Observable = assessmentSection.HydraulicBoundaryDatabase.Locations }; waterLevelCalculationsForSignalFloodingProbabilityObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver( assessmentSection.WaterLevelCalculationsForSignalFloodingProbability, UpdateFeatures); waterLevelCalculationsForMaximumAllowableFloodingProbabilityObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver( assessmentSection.WaterLevelCalculationsForMaximumAllowableFloodingProbability, UpdateFeatures); waterLevelForUserDefinedTargetProbabilitiesCollectionObserver = new Observer(() => { DeleteTargetProbabilitiesObservers(waterLevelCalculationsForTargetProbabilityObservers); CreateTargetProbabilitiesObservers(assessmentSection.WaterLevelCalculationsForUserDefinedTargetProbabilities, waterLevelCalculationsForTargetProbabilityObservers); UpdateFeatures(); }) { Observable = assessmentSection.WaterLevelCalculationsForUserDefinedTargetProbabilities }; waveHeightForUserDefinedTargetProbabilitiesCollectionObserver = new Observer(() => { DeleteTargetProbabilitiesObservers(waveHeightCalculationsForTargetProbabilityObservers); CreateTargetProbabilitiesObservers(assessmentSection.WaveHeightCalculationsForUserDefinedTargetProbabilities, waveHeightCalculationsForTargetProbabilityObservers); UpdateFeatures(); }) { Observable = assessmentSection.WaveHeightCalculationsForUserDefinedTargetProbabilities }; waterLevelForUserDefinedTargetProbabilitiesObserver = new RecursiveObserver <IObservableEnumerable <HydraulicBoundaryLocationCalculationsForTargetProbability>, HydraulicBoundaryLocationCalculationsForTargetProbability>( UpdateFeatures, tp => tp) { Observable = assessmentSection.WaterLevelCalculationsForUserDefinedTargetProbabilities }; waveHeightForUserDefinedTargetProbabilitiesObserver = new RecursiveObserver <IObservableEnumerable <HydraulicBoundaryLocationCalculationsForTargetProbability>, HydraulicBoundaryLocationCalculationsForTargetProbability>( UpdateFeatures, tp => tp) { Observable = assessmentSection.WaveHeightCalculationsForUserDefinedTargetProbabilities }; waterLevelCalculationsForTargetProbabilityObservers = new List <RecursiveObserver <IObservableEnumerable <HydraulicBoundaryLocationCalculation>, HydraulicBoundaryLocationCalculation> >(); CreateTargetProbabilitiesObservers(assessmentSection.WaterLevelCalculationsForUserDefinedTargetProbabilities, waterLevelCalculationsForTargetProbabilityObservers); waveHeightCalculationsForTargetProbabilityObservers = new List <RecursiveObserver <IObservableEnumerable <HydraulicBoundaryLocationCalculation>, HydraulicBoundaryLocationCalculation> >(); CreateTargetProbabilitiesObservers(assessmentSection.WaveHeightCalculationsForUserDefinedTargetProbabilities, waveHeightCalculationsForTargetProbabilityObservers); }
public void CreateHydraulicBoundaryLocationCalculationsObserver_WithData_ReturnsRecursiveObserver() { // Setup var calculations = new ObservableList <HydraulicBoundaryLocationCalculation>(); // Call using (RecursiveObserver <IObservableEnumerable <HydraulicBoundaryLocationCalculation>, HydraulicBoundaryLocationCalculation> observer = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver(calculations, () => {})) { // Assert Assert.AreSame(calculations, observer.Observable); } }
public void CreateHydraulicBoundaryLocationCalculationsObserver_UpdateObserverActionNull_ThrowsArgumentNullException() { // Setup var mocks = new MockRepository(); var calculations = mocks.Stub <IObservableEnumerable <HydraulicBoundaryLocationCalculation> >(); mocks.ReplayAll(); // Call TestDelegate call = () => ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver(calculations, null); // Assert var exception = Assert.Throws <ArgumentNullException>(call); Assert.AreEqual("updateObserverAction", exception.ParamName); mocks.VerifyAll(); }
public void GivenCreatedHydraulicBoundaryLocationCalculationsObserver_WhenCalculationNotifiesObservers_ThenUpdateObserverActionCalled() { // Given var count = 0; var calculation = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation()); var calculations = new ObservableList <HydraulicBoundaryLocationCalculation> { calculation }; using (ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver(calculations, () => { count++; })) { // When calculation.NotifyObservers(); // Then Assert.AreEqual(1, count); } }
private void CreateTargetProbabilitiesObservers(IEnumerable <HydraulicBoundaryLocationCalculationsForTargetProbability> calculationsForUserDefinedTargetProbabilities, List <RecursiveObserver <IObservableEnumerable <HydraulicBoundaryLocationCalculation>, HydraulicBoundaryLocationCalculation> > observers) { observers.AddRange(calculationsForUserDefinedTargetProbabilities.Select(calculationsForTargetProbability => ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver( calculationsForTargetProbability.HydraulicBoundaryLocationCalculations, UpdateFeatures))); }