public void DynamicReadOnlyValidationMethod_WithCreateZonesAndZoningBoundariesDeterminationType_ReturnsExpectedValues( bool createZones, MacroStabilityInwardsZoningBoundariesDeterminationType zoningBoundariesDeterminationType, bool expectedDeterminationTypeReadOnly, bool expectedZoneBoundariesReadOnly) { // Setup var mocks = new MockRepository(); var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>(); mocks.ReplayAll(); var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()) { CreateZones = createZones, ZoningBoundariesDeterminationType = zoningBoundariesDeterminationType }; var properties = new MacroStabilityInwardsSlipPlaneSettingsProperties(input, changeHandler); // Call bool isZoningBoundariesDeterminationTypeReadOnly = properties.DynamicReadOnlyValidationMethod(nameof(properties.ZoningBoundariesDeterminationType)); bool isZoneBoundaryLeftReadOnly = properties.DynamicReadOnlyValidationMethod(nameof(properties.ZoneBoundaryLeft)); bool isZoneBoundaryRightReadOnly = properties.DynamicReadOnlyValidationMethod(nameof(properties.ZoneBoundaryRight)); // Assert Assert.AreEqual(expectedDeterminationTypeReadOnly, isZoningBoundariesDeterminationTypeReadOnly); Assert.AreEqual(expectedZoneBoundariesReadOnly, isZoneBoundaryLeftReadOnly); Assert.AreEqual(expectedZoneBoundariesReadOnly, isZoneBoundaryRightReadOnly); }
private static void SetPropertyAndVerifyNotifications(Action <MacroStabilityInwardsSlipPlaneSettingsProperties> setProperty) { // Setup var mocks = new MockRepository(); var observable = mocks.StrictMock <IObservable>(); observable.Expect(o => o.NotifyObservers()); mocks.ReplayAll(); var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()); var handler = new SetPropertyValueAfterConfirmationParameterTester(new[] { observable }); var properties = new MacroStabilityInwardsSlipPlaneSettingsProperties(input, handler); // Call setProperty(properties); // Assert Assert.IsTrue(handler.Called); mocks.VerifyAll(); }
public void GivenPropertiesWithData_WhenChangingProperties_ThenPropertiesSetOnInput() { // Given var calculation = new MacroStabilityInwardsCalculationScenario(); MacroStabilityInwardsInput input = calculation.InputParameters; var handler = new ObservablePropertyChangeHandler(calculation, input); var properties = new MacroStabilityInwardsSlipPlaneSettingsProperties(input, handler); var random = new Random(21); bool createZones = random.NextBoolean(); var determinationType = random.NextEnumValue <MacroStabilityInwardsZoningBoundariesDeterminationType>(); RoundedDouble boundaryLeft = random.NextRoundedDouble(); RoundedDouble boundaryRight = random.NextRoundedDouble(); // When properties.CreateZones = createZones; properties.ZoningBoundariesDeterminationType = determinationType; properties.ZoneBoundaryLeft = boundaryLeft; properties.ZoneBoundaryRight = boundaryRight; // Then Assert.AreEqual(createZones, input.CreateZones); Assert.AreEqual(determinationType, input.ZoningBoundariesDeterminationType); Assert.AreEqual(boundaryLeft, input.ZoneBoundaryLeft, input.ZoneBoundaryLeft.GetAccuracy()); Assert.AreEqual(boundaryRight, input.ZoneBoundaryRight, input.ZoneBoundaryRight.GetAccuracy()); }
public void ToString_Always_ReturnEmptyString() { // Setup var mocks = new MockRepository(); var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>(); mocks.ReplayAll(); var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()); var properties = new MacroStabilityInwardsSlipPlaneSettingsProperties(input, changeHandler); // Call string toString = properties.ToString(); // Assert Assert.AreEqual(string.Empty, toString); }
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 MacroStabilityInwardsSlipPlaneSettingsProperties(input, changeHandler); // Assert Assert.IsInstanceOf <ObjectProperties <MacroStabilityInwardsInput> >(properties); Assert.AreSame(input, properties.Data); mocks.VerifyAll(); }
public void DynamicReadOnlyValidationMethod_AnyOtherParameter_ReturnsFalse() { // Setup var mocks = new MockRepository(); var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>(); mocks.ReplayAll(); var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()); var properties = new MacroStabilityInwardsSlipPlaneSettingsProperties(input, changeHandler); // Call bool isReadOnly = properties.DynamicReadOnlyValidationMethod("test parameter name 123"); // Assert Assert.IsFalse(isReadOnly); }
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 MacroStabilityInwardsSlipPlaneSettingsProperties(input, changeHandler); // Assert Assert.AreEqual(input.CreateZones, properties.CreateZones); Assert.AreEqual(input.ZoningBoundariesDeterminationType, properties.ZoningBoundariesDeterminationType); Assert.AreEqual(input.ZoneBoundaryLeft, properties.ZoneBoundaryLeft); Assert.AreEqual(input.ZoneBoundaryRight, properties.ZoneBoundaryRight); mocks.VerifyAll(); }
public void Constructor_ValidData_PropertiesHaveExpectedAttributesValues( bool createZones, MacroStabilityInwardsZoningBoundariesDeterminationType zoningBoundariesDeterminationType, bool expectedDeterminationTypeReadOnly, bool expectedZoneBoundariesReadOnly) { // Setup var mocks = new MockRepository(); var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>(); mocks.ReplayAll(); var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()) { CreateZones = createZones, ZoningBoundariesDeterminationType = zoningBoundariesDeterminationType }; // Call var properties = new MacroStabilityInwardsSlipPlaneSettingsProperties(input, changeHandler); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(4, dynamicProperties.Count); const string category = "Zonering glijvlak"; PropertyDescriptor createZonesProperty = dynamicProperties[expectedCreateZonesPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( createZonesProperty, category, "Bepaling", "Gebruik zoneringsgrenzen bij het bepalen van het intredepunt van het glijvlak?"); PropertyDescriptor zoningBoundariesDeterminationTypeProperty = dynamicProperties[expectedZoningBoundariesDeterminationTypePropertyIndex]; TestHelper.AssertTypeConverter <MacroStabilityInwardsSlipPlaneSettingsProperties, EnumTypeConverter>(nameof(properties.ZoningBoundariesDeterminationType)); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( zoningBoundariesDeterminationTypeProperty, category, "Methode", "Zoneringsgrenzen automatisch bepalen of handmatig invoeren?", expectedDeterminationTypeReadOnly); PropertyDescriptor zoneBoundaryLeftProperty = dynamicProperties[expectedZoneBoundayrLeftPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( zoneBoundaryLeftProperty, category, "Zoneringsgrens links", "Linker grens voor bepaling intredepunt van het glijvlak.", expectedZoneBoundariesReadOnly); PropertyDescriptor zoneBoundaryRightProperty = dynamicProperties[expectedZoneBoundaryRightPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( zoneBoundaryRightProperty, category, "Zoneringsgrens rechts", "Rechter grens voor bepaling intredepunt van het glijvlak.", expectedZoneBoundariesReadOnly); mocks.VerifyAll(); }