public void DynamicReadOnly_TangentLineDeterminationType_ReturnsExpectedResult( [Values(true, false)] bool isTangentlineDeterminationTypeLayerSeparated, [Values(true, false)] bool isGridDeterminationTypeAutomatic, [Values(nameof(MacroStabilityInwardsGridSettingsProperties.TangentLineZTop), nameof(MacroStabilityInwardsGridSettingsProperties.TangentLineZBottom), nameof(MacroStabilityInwardsGridSettingsProperties.TangentLineNumber))] string propertyName) { // Setup var mocks = new MockRepository(); var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>(); mocks.ReplayAll(); var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()) { TangentLineDeterminationType = isTangentlineDeterminationTypeLayerSeparated ? MacroStabilityInwardsTangentLineDeterminationType.LayerSeparated : MacroStabilityInwardsTangentLineDeterminationType.Specified, GridDeterminationType = isGridDeterminationTypeAutomatic ? MacroStabilityInwardsGridDeterminationType.Automatic : MacroStabilityInwardsGridDeterminationType.Manual }; var properties = new MacroStabilityInwardsGridSettingsProperties(input, changeHandler); // Call bool result = properties.DynamicReadOnlyValidationMethod(propertyName); // Assert Assert.AreEqual(isTangentlineDeterminationTypeLayerSeparated || isGridDeterminationTypeAutomatic, result); }
private static void SetPropertyAndVerifyNotificationsForCalculation(Action <MacroStabilityInwardsGridSettingsProperties> 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 MacroStabilityInwardsGridSettingsProperties(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 MacroStabilityInwardsGridSettingsProperties(input, handler); var random = new Random(21); bool moveGrid = random.NextBoolean(); var gridDeterminationType = random.NextEnumValue <MacroStabilityInwardsGridDeterminationType>(); var tangentLineDeterminationType = random.NextEnumValue <MacroStabilityInwardsTangentLineDeterminationType>(); double tangentLineZTop = random.NextDouble(2.0, 3.0); double tangentLineZBottom = random.NextDouble(0.0, 1.0); int tangentLineNumber = random.Next(1, 51); // When properties.MoveGrid = moveGrid; properties.GridDeterminationType = gridDeterminationType; properties.TangentLineDeterminationType = tangentLineDeterminationType; properties.TangentLineZTop = (RoundedDouble)tangentLineZTop; properties.TangentLineZBottom = (RoundedDouble)tangentLineZBottom; properties.TangentLineNumber = tangentLineNumber; // Then Assert.AreEqual(moveGrid, input.MoveGrid); Assert.AreEqual(gridDeterminationType, input.GridDeterminationType); Assert.AreEqual(tangentLineDeterminationType, input.TangentLineDeterminationType); Assert.AreEqual(tangentLineZTop, input.TangentLineZTop, input.TangentLineZTop.GetAccuracy()); Assert.AreEqual(tangentLineZBottom, input.TangentLineZBottom, input.TangentLineZBottom.GetAccuracy()); Assert.AreEqual(tangentLineNumber, input.TangentLineNumber); }
public void GetProperties_WithData_ReturnExpectedValues( MacroStabilityInwardsGridDeterminationType gridDeterminationType) { // Setup var mocks = new MockRepository(); var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>(); mocks.ReplayAll(); var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()) { GridDeterminationType = gridDeterminationType }; // Call var properties = new MacroStabilityInwardsGridSettingsProperties(input, changeHandler); // Assert Assert.AreEqual(input.MoveGrid, properties.MoveGrid); Assert.AreEqual(input.GridDeterminationType, properties.GridDeterminationType); Assert.AreEqual(input.TangentLineDeterminationType, properties.TangentLineDeterminationType); Assert.AreEqual(input.TangentLineZTop, properties.TangentLineZTop); Assert.AreEqual(input.TangentLineZBottom, properties.TangentLineZBottom); Assert.AreEqual(input.TangentLineNumber, properties.TangentLineNumber); bool gridIsReadOnly = gridDeterminationType == MacroStabilityInwardsGridDeterminationType.Automatic; Assert.AreSame(input.LeftGrid, properties.LeftGrid.Data); Assert.AreEqual(gridIsReadOnly, properties.LeftGrid.DynamicReadOnlyValidationMethod(string.Empty)); Assert.AreSame(input.RightGrid, properties.RightGrid.Data); Assert.AreEqual(gridIsReadOnly, properties.RightGrid.DynamicReadOnlyValidationMethod(string.Empty)); mocks.VerifyAll(); }
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 MacroStabilityInwardsGridSettingsProperties(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 MacroStabilityInwardsGridSettingsProperties(input, changeHandler); // Assert Assert.IsInstanceOf <ObjectProperties <MacroStabilityInwardsInput> >(properties); Assert.AreSame(input, properties.Data); mocks.VerifyAll(); }
public void DynamicReadOnly_GridDeterminationType_ReturnsExpectedResult(bool isGridDeterminationTypeAutomatic) { // Setup var mocks = new MockRepository(); var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>(); mocks.ReplayAll(); var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties()) { GridDeterminationType = isGridDeterminationTypeAutomatic ? MacroStabilityInwardsGridDeterminationType.Automatic : MacroStabilityInwardsGridDeterminationType.Manual }; var properties = new MacroStabilityInwardsGridSettingsProperties(input, changeHandler); // Call bool result = properties.DynamicReadOnlyValidationMethod(string.Empty); // Assert Assert.AreEqual(isGridDeterminationTypeAutomatic, result); }
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 MacroStabilityInwardsGridSettingsProperties(input, changeHandler); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(8, dynamicProperties.Count); const string calculationGridsCategory = "Rekengrids"; PropertyDescriptor moveGridProperty = dynamicProperties[expectedMoveGridPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( moveGridProperty, calculationGridsCategory, "Verplaats grid", "Sta automatische aanpassing van het grid toe?"); PropertyDescriptor gridDeterminationTypeProperty = dynamicProperties[expectedGridDeterminationTypePropertyIndex]; TestHelper.AssertTypeConverter <MacroStabilityInwardsGridSettingsProperties, EnumTypeConverter>(nameof(properties.GridDeterminationType)); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( gridDeterminationTypeProperty, calculationGridsCategory, "Bepaling grid", "Rekengrid automatisch bepalen of handmatig invoeren?"); PropertyDescriptor tangentLineDeterminationTypeProperty = dynamicProperties[expectedTangentLineDeterminationTypePropertyIndex]; TestHelper.AssertTypeConverter <MacroStabilityInwardsGridSettingsProperties, EnumTypeConverter>(nameof(properties.TangentLineDeterminationType)); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( tangentLineDeterminationTypeProperty, calculationGridsCategory, "Bepaling tangentlijnen", "Bepaling raaklijnen op basis van grondlaagscheidingen of handmatig?", true); PropertyDescriptor tangentLineZTopProperty = dynamicProperties[expectedTangentLineZTopPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( tangentLineZTopProperty, calculationGridsCategory, "Tangentlijn Z-boven [m+NAP]", "Verticale coördinaat van de bovenste raaklijn.", true); PropertyDescriptor tangentLineZBottomProperty = dynamicProperties[expectedTangentLineZBottomPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( tangentLineZBottomProperty, calculationGridsCategory, "Tangentlijn Z-onder [m+NAP]", "Verticale coördinaat van de onderste raaklijn.", true); PropertyDescriptor tangentLineNumberProperty = dynamicProperties[expectedTangentLineNumberPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( tangentLineNumberProperty, calculationGridsCategory, "Aantal tangentlijnen", "Het aantal raaklijnen dat bepaald moet worden.", true); PropertyDescriptor leftGridProperty = dynamicProperties[expectedLeftGridPropertyIndex]; TestHelper.AssertTypeConverter <MacroStabilityInwardsGridSettingsProperties, ExpandableObjectConverter>(nameof(properties.LeftGrid)); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( leftGridProperty, calculationGridsCategory, "Linker grid", "Eigenschappen van het linker grid.", true); PropertyDescriptor rightGridProperty = dynamicProperties[expectedRightGridPropertyIndex]; TestHelper.AssertTypeConverter <MacroStabilityInwardsGridSettingsProperties, ExpandableObjectConverter>(nameof(properties.RightGrid)); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( rightGridProperty, calculationGridsCategory, "Rechter grid", "Eigenschappen van het rechter grid.", true); mocks.VerifyAll(); }