public void Constructor_ValidParameters_ExpectedValues() { // Setup var random = new Random(39); FailureMechanismSection section = GetTestFailureMechanismSection(); double sectionStart = random.NextDouble(); double sectionEnd = random.NextDouble(); var probabilityAssessmentInput = new TestProbabilityAssessmentInput(random.NextDouble(), random.NextDouble()); // Call var sectionRow = new FailureMechanismSectionProbabilityAssessmentRow(section, sectionStart, sectionEnd, probabilityAssessmentInput); // Assert Assert.IsInstanceOf <FailureMechanismSectionRow>(sectionRow); Assert.AreEqual(section.Name, sectionRow.Name); Assert.AreEqual(sectionStart, sectionRow.SectionStart, sectionRow.SectionStart.GetAccuracy()); Assert.AreEqual(sectionEnd, sectionRow.SectionEnd, sectionRow.SectionEnd.GetAccuracy()); Assert.AreEqual(section.Length, sectionRow.Length, sectionRow.Length.GetAccuracy()); Assert.AreEqual(2, sectionRow.N.NumberOfDecimalPlaces); AssertLengthEffect(probabilityAssessmentInput, section, sectionRow); }
public void GetN_WithValues_ReturnsExpectedResult(double a, double b, double length, double expectedN) { // Setup var input = new TestProbabilityAssessmentInput(a, b); // Call double actualN = input.GetN(length); // Assert Assert.AreEqual(expectedN, actualN); }
public void Constructor_ExpectedValues() { // Call var random = new Random(39); double a = random.NextDouble(); double b = random.NextDouble(); var probabilityAssessmentInput = new TestProbabilityAssessmentInput(a, b); // Assert Assert.AreEqual(a, probabilityAssessmentInput.A); Assert.AreEqual(b, probabilityAssessmentInput.B); }
public void A_ValidValue_SetsValue(double a) { // Setup var random = new Random(39); var probabilityAssessmentInput = new TestProbabilityAssessmentInput(random.NextDouble(), random.NextDouble()); // Call probabilityAssessmentInput.A = a; // Assert Assert.AreEqual(a, probabilityAssessmentInput.A); }
public void Constructor_FailureMechanismNull_ThrowsArgumentNullException() { // Setup var random = new Random(39); var probabilityAssessmentInput = new TestProbabilityAssessmentInput(random.NextDouble(), random.NextDouble()); // Call void Call() => new FailureMechanismSectionsProbabilityAssessmentProperties(null, probabilityAssessmentInput); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("failureMechanism", exception.ParamName); }
public void Constructor_ExpectedValues() { // Setup var failureMechanism = new TestFailureMechanism(); string sourcePath = TestHelper.GetScratchPadPath(); var random = new Random(39); var probabilityAssessmentInput = new TestProbabilityAssessmentInput(random.NextDouble(), random.NextDouble()); IEnumerable <FailureMechanismSection> sections = new[] { FailureMechanismSectionTestFactory.CreateFailureMechanismSection() }; failureMechanism.SetSections(sections, sourcePath); // Call using (var properties = new FailureMechanismSectionsProbabilityAssessmentProperties( failureMechanism, probabilityAssessmentInput)) { // Assert Assert.IsInstanceOf <ObjectProperties <IFailureMechanism> >(properties); Assert.IsInstanceOf <IDisposable>(properties); Assert.AreSame(failureMechanism, properties.Data); TestHelper.AssertTypeConverter <FailureMechanismSectionsProperties, ExpandableArrayConverter>( nameof(FailureMechanismSectionsProperties.Sections)); Assert.AreEqual(sections.Count(), properties.Sections.Length); double sectionStart = 0; for (var i = 0; i < sections.Count(); i++) { FailureMechanismSection section = sections.ElementAt(i); FailureMechanismSectionProbabilityAssessmentProperties property = properties.Sections[i]; Assert.AreSame(section, property.Data); Assert.AreEqual(1 + probabilityAssessmentInput.A * section.Length / probabilityAssessmentInput.B, property.N, property.N.GetAccuracy()); double sectionEnd = sectionStart + section.Length; Assert.AreEqual(sectionStart, property.SectionStart, property.SectionStart.GetAccuracy()); Assert.AreEqual(sectionEnd, property.SectionEnd, property.SectionEnd.GetAccuracy()); sectionStart = sectionEnd; } Assert.AreEqual(sourcePath, properties.SourcePath); } }
public void A_InvalidValue_ThrowsArgumentOutOfRangeException(double a) { // Setup var random = new Random(39); var probabilityAssessmentInput = new TestProbabilityAssessmentInput(random.NextDouble(), random.NextDouble()); // Call TestDelegate call = () => probabilityAssessmentInput.A = a; // Assert const string expectedMessage = "De waarde voor 'a' moet in het bereik [0,0, 1,0] liggen."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentOutOfRangeException>(call, expectedMessage); }
public void GivenRow_WhenProbabilityAssessmentInputChanged_ThenLengthEffectChangedAccordingly() { // Given var random = new Random(39); FailureMechanismSection section = GetTestFailureMechanismSection(); var probabilityAssessmentInput = new TestProbabilityAssessmentInput(random.NextDouble(), random.NextDouble()); var sectionRow = new FailureMechanismSectionProbabilityAssessmentRow(section, double.NaN, double.NaN, probabilityAssessmentInput); // Precondition AssertLengthEffect(probabilityAssessmentInput, section, sectionRow); // When probabilityAssessmentInput.A = random.NextDouble(); // Then AssertLengthEffect(probabilityAssessmentInput, section, sectionRow); }
public void GivenPropertyControlWithData_WhenFailureMechanismUpdated_RefreshRequiredEventRaised() { // Given var random = new Random(39); var probabilityAssessmentInput = new TestProbabilityAssessmentInput(random.NextDouble(), random.NextDouble()); var failureMechanism = new TestFailureMechanism(); using (var properties = new FailureMechanismSectionsProbabilityAssessmentProperties( failureMechanism, probabilityAssessmentInput)) { var refreshRequiredRaised = 0; properties.RefreshRequired += (sender, args) => refreshRequiredRaised++; // When failureMechanism.NotifyObservers(); // Then Assert.AreEqual(1, refreshRequiredRaised); } }
public void Constructor_Always_PropertiesHaveExpectedAttributesValues() { // Setup var mocks = new MockRepository(); var failureMechanism = mocks.Stub <IFailureMechanism>(); mocks.ReplayAll(); var random = new Random(39); var probabilityAssessmentInput = new TestProbabilityAssessmentInput(random.NextDouble(), random.NextDouble()); // Call using (var properties = new FailureMechanismSectionsProbabilityAssessmentProperties( failureMechanism, probabilityAssessmentInput)) { // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(2, dynamicProperties.Count); var generalCategoryName = "Algemeen"; PropertyDescriptor sourcePathProperty = dynamicProperties[0]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(sourcePathProperty, generalCategoryName, "Bronlocatie", "De locatie van het bestand waaruit de vakindeling is geïmporteerd.", true); PropertyDescriptor sectionsProperty = dynamicProperties[1]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(sectionsProperty, generalCategoryName, "Vakindeling", "Vakindeling waarmee de waterkering voor dit faalmechanisme is " + "geschematiseerd ten behoeve van de beoordeling.", true); mocks.VerifyAll(); } }
public void Constructor_ExpectedValues() { // Setup var random = new Random(21); double sectionStart = random.NextDouble(); double sectionEnd = random.NextDouble(); var probabilityAssessmentInput = new TestProbabilityAssessmentInput(0.5, 100); FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); // Call var properties = new FailureMechanismSectionProbabilityAssessmentProperties(section, sectionStart, sectionEnd, probabilityAssessmentInput); // Assert Assert.IsInstanceOf <FailureMechanismSectionProperties>(properties); Assert.AreSame(section, properties.Data); TestHelper.AssertTypeConverter <FailureMechanismSectionProbabilityAssessmentProperties, ExpandableObjectConverter>(); Assert.AreEqual(2, properties.N.NumberOfDecimalPlaces); Assert.AreEqual(1.0, properties.N, properties.N.GetAccuracy()); Assert.AreEqual(sectionStart, properties.SectionStart, properties.SectionStart.GetAccuracy()); Assert.AreEqual(sectionEnd, properties.SectionEnd, properties.SectionEnd.GetAccuracy()); }
public void Constructor_Always_PropertiesHaveExpectedAttributesValues() { // Setup var probabilityAssessmentInput = new TestProbabilityAssessmentInput(0.5, 100); FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); // Call var properties = new FailureMechanismSectionProbabilityAssessmentProperties(section, double.NaN, double.NaN, probabilityAssessmentInput); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(7, dynamicProperties.Count); PropertyDescriptor nameProperty = dynamicProperties[0]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, "Algemeen", "Vaknaam", "De naam van het vak.", true); PropertyDescriptor sectionStartDistanceProperty = dynamicProperties[1]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(sectionStartDistanceProperty, "Algemeen", "Metrering van* [m]", "De afstand tussen het beginpunt van het vak en het begin van het traject, gemeten langs het traject in meters (afgerond).", true); PropertyDescriptor sectionEndDistanceProperty = dynamicProperties[2]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(sectionEndDistanceProperty, "Algemeen", "Metrering tot* [m]", "De afstand tussen het eindpunt van het vak en het begin van het traject, gemeten langs het traject in meters (afgerond).", true); PropertyDescriptor lengthProperty = dynamicProperties[3]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(lengthProperty, "Algemeen", "Lengte* [m]", "De totale lengte van het vak in meters (afgerond).", true); PropertyDescriptor startPointProperty = dynamicProperties[4]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(startPointProperty, "Algemeen", "Beginpunt", "Beginpunt van het vak (X-coördinaat, Y-coördinaat).", true); PropertyDescriptor endPointProperty = dynamicProperties[5]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(endPointProperty, "Algemeen", "Eindpunt", "Eindpunt van het vak (X-coördinaat, Y-coördinaat).", true); PropertyDescriptor nProperty = dynamicProperties[6]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nProperty, "Algemeen", "Nvak* [-]", "Vakspecifieke waarde voor het in rekening brengen van " + "het lengte-effect tijdens assemblage (afgerond).", true); }