public void Constructor_ExpectedValues() { // Setup var random = new Random(21); var failureMechanism = new HeightStructuresFailureMechanism { InAssembly = random.NextBoolean() }; // Call var properties = new HeightStructuresFailureMechanismProperties(failureMechanism); // Assert Assert.IsInstanceOf <HeightStructuresFailureMechanismPropertiesBase>(properties); Assert.AreEqual(failureMechanism.Name, properties.Name); Assert.AreEqual(failureMechanism.Code, properties.Code); Assert.AreEqual(failureMechanism.InAssembly, properties.InAssembly); GeneralHeightStructuresInput generalInput = failureMechanism.GeneralInput; Assert.AreEqual(2, properties.N.NumberOfDecimalPlaces); Assert.AreEqual(generalInput.N, properties.N, properties.N.GetAccuracy()); Assert.AreEqual(generalInput.ApplyLengthEffectInSection, properties.ApplyLengthEffectInSection); }
public void Constructor_Always_PropertiesHaveExpectedAttributeValues() { // Call var properties = new HeightStructuresFailureMechanismProperties(new HeightStructuresFailureMechanism()); // Assert const string generalCategory = "Algemeen"; const string modelSettingsCategory = "Modelinstellingen"; PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(5, dynamicProperties.Count); PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, generalCategory, "Naam", "De naam van het faalmechanisme.", true); PropertyDescriptor codeProperty = dynamicProperties[codePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(codeProperty, generalCategory, "Label", "Het label van het faalmechanisme.", true); PropertyDescriptor gravitationalAccelerationProperty = dynamicProperties[gravitationalAccelerationPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(gravitationalAccelerationProperty, generalCategory, "Valversnelling [m/s²]", "Valversnelling.", true); PropertyDescriptor modelFactorOvertoppingFlowProperty = dynamicProperties[modelFactorOvertoppingFlowPropertyIndex]; Assert.IsInstanceOf <ExpandableObjectConverter>(modelFactorOvertoppingFlowProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(modelFactorOvertoppingFlowProperty, modelSettingsCategory, "Modelfactor overslagdebiet [-]", "Modelfactor voor het overslagdebiet.", true); PropertyDescriptor modelFactorStorageVolumeProperty = dynamicProperties[modelFactorStorageVolumePropertyIndex]; Assert.IsInstanceOf <ExpandableObjectConverter>(modelFactorStorageVolumeProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(modelFactorStorageVolumeProperty, modelSettingsCategory, "Modelfactor kombergend vermogen [-]", "Modelfactor kombergend vermogen.", true); }
public void Constructor_InAssemblyTrue_PropertiesHaveExpectedAttributesValues() { // Setup var failureMechanism = new HeightStructuresFailureMechanism(); // Call var properties = new HeightStructuresFailureMechanismProperties(failureMechanism); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(5, dynamicProperties.Count); const string generalCategory = "Algemeen"; const string lengthEffectCategory = "Lengte-effect"; PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, generalCategory, "Naam", "De naam van het faalmechanisme.", true); PropertyDescriptor labelProperty = dynamicProperties[codePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(labelProperty, generalCategory, "Label", "Het label van het faalmechanisme.", true); PropertyDescriptor inAssemblyProperty = dynamicProperties[inAssemblyPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(inAssemblyProperty, generalCategory, "In assemblage", "Geeft aan of dit faalmechanisme wordt meegenomen in de assemblage.", true); PropertyDescriptor nProperty = dynamicProperties[nPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nProperty, lengthEffectCategory, "N [-]", "De parameter 'N' die gebruikt wordt om het lengte-effect mee te nemen in de beoordeling."); PropertyDescriptor applySectionLengthInSectionProperty = dynamicProperties[applyLengthEffectInSectionPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(applySectionLengthInSectionProperty, lengthEffectCategory, "Toepassen lengte-effect binnen vak", "Geeft aan of het lengte-effect binnen een vak toegepast wordt.", true); }
public void DynamicVisibleValidationMethod_DependingOnInAssembly_ReturnExpectedVisibility(bool inAssembly) { // Setup var failureMechanism = new HeightStructuresFailureMechanism { InAssembly = inAssembly }; var properties = new HeightStructuresFailureMechanismProperties(failureMechanism); // Call & Assert Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Name))); Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Code))); Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.InAssembly))); Assert.AreEqual(inAssembly, properties.DynamicVisibleValidationMethod(nameof(properties.N))); Assert.AreEqual(inAssembly, properties.DynamicVisibleValidationMethod(nameof(properties.ApplyLengthEffectInSection))); Assert.IsTrue(properties.DynamicVisibleValidationMethod(null)); }
public void Constructor_InAssemblyFalse_PropertiesHaveExpectedAttributesValues() { // Setup var failureMechanism = new HeightStructuresFailureMechanism { InAssembly = false }; // Call var properties = new HeightStructuresFailureMechanismProperties(failureMechanism); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(3, dynamicProperties.Count); const string generalCategory = "Algemeen"; PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, generalCategory, "Naam", "De naam van het faalmechanisme.", true); PropertyDescriptor labelProperty = dynamicProperties[codePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(labelProperty, generalCategory, "Label", "Het label van het faalmechanisme.", true); PropertyDescriptor inAssemblyProperty = dynamicProperties[inAssemblyPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(inAssemblyProperty, generalCategory, "In assemblage", "Geeft aan of dit faalmechanisme wordt meegenomen in de assemblage.", true); }
public void N_SetValidValue_UpdateDataAndNotifyObservers(double newN) { // Setup var mocks = new MockRepository(); var observer = mocks.StrictMock <IObserver>(); observer.Expect(o => o.UpdateObserver()); mocks.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism(); failureMechanism.Attach(observer); var properties = new HeightStructuresFailureMechanismProperties(failureMechanism); // Call properties.N = (RoundedDouble)newN; // Assert Assert.AreEqual(newN, failureMechanism.GeneralInput.N, failureMechanism.GeneralInput.N.GetAccuracy()); mocks.VerifyAll(); }
public void Constructor_ExpectedValues() { // Setup var failureMechanism = new HeightStructuresFailureMechanism(); // Call var properties = new HeightStructuresFailureMechanismProperties(failureMechanism); // Assert Assert.IsInstanceOf <HeightStructuresFailureMechanismPropertiesBase>(properties); Assert.AreSame(failureMechanism, properties.Data); Assert.AreEqual(failureMechanism.Name, properties.Name); Assert.AreEqual(failureMechanism.Code, properties.Code); GeneralHeightStructuresInput generalInput = failureMechanism.GeneralInput; Assert.AreEqual(generalInput.GravitationalAcceleration, properties.GravitationalAcceleration); Assert.AreEqual(generalInput.ModelFactorOvertoppingFlow.Mean, properties.ModelFactorOvertoppingFlow.Mean); Assert.AreEqual(generalInput.ModelFactorOvertoppingFlow.StandardDeviation, properties.ModelFactorOvertoppingFlow.StandardDeviation); Assert.AreEqual(generalInput.ModelFactorStorageVolume.Mean, properties.ModelFactorStorageVolume.Mean); Assert.AreEqual(generalInput.ModelFactorStorageVolume.StandardDeviation, properties.ModelFactorStorageVolume.StandardDeviation); }
public void N_SetInvalidValue_ThrowsArgumentOutOfRangeExceptionNoNotifications(double newN) { // Setup var mocks = new MockRepository(); var observer = mocks.StrictMock <IObserver>(); mocks.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism(); failureMechanism.Attach(observer); var properties = new HeightStructuresFailureMechanismProperties(failureMechanism); // Call void Call() => properties.N = (RoundedDouble)newN; // Assert const string expectedMessage = "De waarde voor 'N' moet in het bereik [1,00, 20,00] liggen."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentOutOfRangeException>(Call, expectedMessage); mocks.VerifyAll(); }