/// <summary>
        /// Creates a new instance of <see cref="MacroStabilityInwardsOutputProperties"/>.
        /// </summary>
        /// <param name="output">The output to show the properties for.</param>
        /// <param name="modelFactor">The model factor used to calculate a reliability from a stability factor.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="output"/> is <c>null</c>.</exception>
        public MacroStabilityInwardsOutputProperties(MacroStabilityInwardsOutput output,
                                                     double modelFactor)
        {
            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            Data = output;

            derivedOutput = DerivedMacroStabilityInwardsOutputFactory.Create(output, modelFactor);
        }
        public void Create_ValidData_ReturnsExpectedValue()
        {
            // Setup
            MacroStabilityInwardsOutput output = MacroStabilityInwardsOutputTestFactory.CreateOutput(new MacroStabilityInwardsOutput.ConstructionProperties
            {
                FactorOfStability = new Random(21).NextDouble()
            });

            // Call
            DerivedMacroStabilityInwardsOutput derivedOutput = DerivedMacroStabilityInwardsOutputFactory.Create(output, 1.1);

            // Assert
            Assert.AreEqual(output.FactorOfStability, derivedOutput.FactorOfStability, derivedOutput.FactorOfStability.GetAccuracy());
            Assert.AreEqual(0.067853, derivedOutput.MacroStabilityInwardsProbability, 1e-6);
            Assert.AreEqual(1.49197, derivedOutput.MacroStabilityInwardsReliability, derivedOutput.MacroStabilityInwardsReliability.GetAccuracy());
        }
Exemplo n.º 3
0
        public void Constructor_ValidMacroStabilityInwardsProbability_ExpectedValues(double macroStabilityInwardsProbability)
        {
            // Setup
            var    random            = new Random(21);
            double factorOfStability = random.NextDouble();
            double macroStabilityInwardsReliability = random.NextDouble();

            // Call
            var output = new DerivedMacroStabilityInwardsOutput(
                factorOfStability,
                macroStabilityInwardsProbability,
                macroStabilityInwardsReliability);

            // Assert
            Assert.AreEqual(macroStabilityInwardsProbability, output.MacroStabilityInwardsProbability);
        }
        public void GetProperties_WithData_ReturnExpectedValues()
        {
            // Setup
            const double modelFactor = 1.1;

            MacroStabilityInwardsOutput output = MacroStabilityInwardsOutputTestFactory.CreateRandomOutput();

            // Call
            var properties = new MacroStabilityInwardsOutputProperties(output, modelFactor);

            // Assert
            DerivedMacroStabilityInwardsOutput expectedDerivedOutput = DerivedMacroStabilityInwardsOutputFactory.Create(output, modelFactor);

            Assert.AreEqual(expectedDerivedOutput.FactorOfStability, properties.MacroStabilityInwardsFactorOfStability,
                            properties.MacroStabilityInwardsFactorOfStability.GetAccuracy());

            Assert.AreEqual(ProbabilityFormattingHelper.Format(expectedDerivedOutput.MacroStabilityInwardsProbability), properties.MacroStabilityInwardsProbability);
            Assert.AreEqual(expectedDerivedOutput.MacroStabilityInwardsReliability, properties.MacroStabilityInwardsReliability, properties.MacroStabilityInwardsReliability.GetAccuracy());
        }
Exemplo n.º 5
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var    random            = new Random(21);
            double factorOfStability = random.NextDouble();
            double macroStabilityInwardsProbability = random.NextDouble();
            double macroStabilityInwardsReliability = random.NextDouble();

            // Call
            var output = new DerivedMacroStabilityInwardsOutput(
                factorOfStability,
                macroStabilityInwardsProbability,
                macroStabilityInwardsReliability);

            // Assert
            Assert.AreEqual(factorOfStability, output.FactorOfStability, output.FactorOfStability.GetAccuracy());
            Assert.AreEqual(3, output.FactorOfStability.NumberOfDecimalPlaces);
            Assert.AreEqual(macroStabilityInwardsProbability, output.MacroStabilityInwardsProbability);
            Assert.AreEqual(5, output.MacroStabilityInwardsReliability.NumberOfDecimalPlaces);
            Assert.AreEqual(macroStabilityInwardsReliability, output.MacroStabilityInwardsReliability, output.MacroStabilityInwardsReliability.GetAccuracy());
        }
Exemplo n.º 6
0
        public void GivenScenarioRow_WhenOutputChangedAndUpdate_ThenDerivedOutputUpdated()
        {
            // Given
            var calculation = new MacroStabilityInwardsCalculationScenario
            {
                Output = MacroStabilityInwardsOutputTestFactory.CreateRandomOutput()
            };
            var failureMechanism = new MacroStabilityInwardsFailureMechanism();
            FailureMechanismSection failureMechanismSection = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();

            var row = new MacroStabilityInwardsScenarioRow(calculation, failureMechanism, failureMechanismSection);

            // Precondition
            DerivedMacroStabilityInwardsOutput expectedDerivedOutput = DerivedMacroStabilityInwardsOutputFactory.Create(calculation.Output, failureMechanism.GeneralInput.ModelFactor);

            Assert.AreEqual(expectedDerivedOutput.MacroStabilityInwardsProbability, row.FailureProbability);
            Assert.AreEqual(expectedDerivedOutput.MacroStabilityInwardsProbability * failureMechanism.MacroStabilityInwardsProbabilityAssessmentInput.GetN(
                                failureMechanismSection.Length),
                            row.SectionFailureProbability);

            var random = new Random(11);

            // When
            calculation.Output = MacroStabilityInwardsOutputTestFactory.CreateOutput(new MacroStabilityInwardsOutput.ConstructionProperties
            {
                FactorOfStability = random.NextDouble()
            });
            row.Update();

            // Then
            DerivedMacroStabilityInwardsOutput newExpectedDerivedOutput = DerivedMacroStabilityInwardsOutputFactory.Create(calculation.Output, failureMechanism.GeneralInput.ModelFactor);

            Assert.AreEqual(newExpectedDerivedOutput.MacroStabilityInwardsProbability, row.FailureProbability);
            Assert.AreEqual(newExpectedDerivedOutput.MacroStabilityInwardsProbability * failureMechanism.MacroStabilityInwardsProbabilityAssessmentInput.GetN(
                                failureMechanismSection.Length),
                            row.SectionFailureProbability);
        }
 private void CreateDerivedOutput()
 {
     derivedOutput = CalculationScenario.HasOutput
                         ? DerivedMacroStabilityInwardsOutputFactory.Create(CalculationScenario.Output, failureMechanism.GeneralInput.ModelFactor)
                         : null;
 }