private static void SetPropertyAndVerifyNotificationsForCalculation(Action <MacroStabilityInwardsLocationInputExtremeProperties> setProperty, MacroStabilityInwardsCalculation calculation) { // Setup var mocks = new MockRepository(); var observable = mocks.StrictMock <IObservable>(); observable.Expect(o => o.NotifyObservers()); mocks.ReplayAll(); MacroStabilityInwardsInput input = calculation.InputParameters; var handler = new SetPropertyValueAfterConfirmationParameterTester(new[] { observable }); var properties = new MacroStabilityInwardsLocationInputExtremeProperties(input, handler); // Call setProperty(properties); // Assert Assert.IsTrue(handler.Called); mocks.VerifyAll(); }
public void Constructor_ValidData_PropertiesHaveExpectedAttributesValues() { // Setup var mocks = new MockRepository(); var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>(); mocks.ReplayAll(); var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()); // Call var properties = new MacroStabilityInwardsLocationInputExtremeProperties(input, changeHandler); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(3, dynamicProperties.Count); const string waterStressesCategory = "Waterspanningen"; PropertyDescriptor waterLevelPolderProperty = dynamicProperties[expectedWaterLevelPolderPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( waterLevelPolderProperty, waterStressesCategory, "Polderpeil [m+NAP]", "Het niveau van het oppervlaktewater binnen een beheersgebied."); PropertyDescriptor offsetProperty = dynamicProperties[expectedOffsetPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( offsetProperty, waterStressesCategory, "Offsets PL 1", "Eigenschappen van offsets PL 1.", true); PropertyDescriptor penetrationLengthProperty = dynamicProperties[expectedPenetrationLengthPropertyIndex]; Assert.IsNotNull(penetrationLengthProperty.Attributes[typeof(DynamicReadOnlyAttribute)]); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( penetrationLengthProperty, waterStressesCategory, "Indringingslengte [m]", "De verticale afstand waarover de waterspanning in de deklaag verandert bij waterspanningsvariaties in de watervoerende zandlaag."); mocks.VerifyAll(); }
public void DynamicReadOnlyValidationMethod_GivenDikeSoilScenario_ReturnsExpectedReadOnly( MacroStabilityInwardsDikeSoilScenario dikeSoilScenario, bool expectedReadOnly) { // Setup var calculation = new MacroStabilityInwardsCalculationScenario { InputParameters = { DikeSoilScenario = dikeSoilScenario } }; var handler = new ObservablePropertyChangeHandler(calculation, calculation.InputParameters); var properties = new MacroStabilityInwardsLocationInputExtremeProperties(calculation.InputParameters, handler); // Call & Assert Assert.AreEqual(expectedReadOnly, properties.DynamicReadOnlyValidationMethod(nameof(MacroStabilityInwardsLocationInputExtremeProperties.PenetrationLength))); }
public void GetProperties_WithData_ReturnExpectedValues() { // Setup var mocks = new MockRepository(); var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>(); mocks.ReplayAll(); var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()); // Call var properties = new MacroStabilityInwardsLocationInputExtremeProperties(input, changeHandler); // Assert Assert.AreEqual(input.LocationInputExtreme.PenetrationLength, properties.PenetrationLength); mocks.VerifyAll(); }
public void Constructor_ExpectedValues() { // Setup var mocks = new MockRepository(); var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>(); mocks.ReplayAll(); var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()); // Call var properties = new MacroStabilityInwardsLocationInputExtremeProperties(input, changeHandler); // Assert Assert.IsInstanceOf <ObjectProperties <MacroStabilityInwardsLocationInputExtreme> >(properties); Assert.AreSame(input.LocationInputExtreme, properties.Data); mocks.VerifyAll(); }
public void GivenPropertiesWithData_WhenChangingProperties_ThenPropertiesSetOnInput() { // Given var calculation = new MacroStabilityInwardsCalculationScenario(); MacroStabilityInwardsInput input = calculation.InputParameters; var handler = new ObservablePropertyChangeHandler(calculation, calculation.InputParameters); var properties = new MacroStabilityInwardsLocationInputExtremeProperties(input, handler); var random = new Random(21); double penetrationLength = random.NextDouble(); // When properties.PenetrationLength = (RoundedDouble)penetrationLength; // Then Assert.AreEqual(penetrationLength, input.LocationInputExtreme.PenetrationLength, input.LocationInputExtreme.PenetrationLength.GetAccuracy()); }