// Copyright (C) Stichting Deltares 2017. All rights reserved.
//
// This file is part of Ringtoets.
//
// Ringtoets is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
//
// All names, logos, and references to "Deltares" are registered trademarks of
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
using System;
using System.Collections.Generic;
using System.Drawing;
using Core.Common.Base;
using Core.Common.Controls.DataGrid;
using Core.Common.TestUtil;
using NUnit.Framework;
using Rhino.Mocks;
using Ringtoets.AssemblyTool.Data;
using Ringtoets.AssemblyTool.KernelWrapper.Calculators;
using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators;
using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.Structures;
using Ringtoets.Common.Data.TestUtil;
using Ringtoets.Common.Forms.Helpers;
using Ringtoets.Common.Forms.TestUtil;
using Ringtoets.Common.Forms.TypeConverters;
using Ringtoets.Common.Forms.Views;
using Ringtoets.Common.Primitives;
using Ringtoets.HeightStructures.Data;
using Ringtoets.HeightStructures.Data.TestUtil;
using Ringtoets.HeightStructures.Forms.Views;
namespace Ringtoets.HeightStructures.Forms.Test.Views
{
[TestFixture]
public class HeightStructuresFailureMechanismSectionResultRowTest
{
private static HeightStructuresFailureMechanismSectionResultRow.ConstructionProperties ConstructionProperties
{
get
{
return new HeightStructuresFailureMechanismSectionResultRow.ConstructionProperties
{
SimpleAssessmentResultIndex = 1,
DetailedAssessmentResultIndex = 2,
DetailedAssessmentProbabilityIndex = 3,
TailorMadeAssessmentResultIndex = 4,
TailorMadeAssessmentProbabilityIndex = 5,
SimpleAssemblyCategoryGroupIndex = 6,
DetailedAssemblyCategoryGroupIndex = 7,
TailorMadeAssemblyCategoryGroupIndex = 8,
CombinedAssemblyCategoryGroupIndex = 9,
CombinedAssemblyProbabilityIndex = 10,
ManualAssemblyProbabilityIndex = 11
};
}
}
[Test]
public void Constructor_FailureMechanismNull_ThrowsArgumentNullException()
{
// Setup
var mocks = new MockRepository();
var assessmentSection = mocks.Stub();
mocks.ReplayAll();
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var result = new HeightStructuresFailureMechanismSectionResult(section);
// Call
TestDelegate test = () => new HeightStructuresFailureMechanismSectionResultRow(
result, null, assessmentSection, ConstructionProperties);
// Assert
string paramName = Assert.Throws(test).ParamName;
Assert.AreEqual("failureMechanism", paramName);
mocks.VerifyAll();
}
[Test]
public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException()
{
// Setup
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var result = new HeightStructuresFailureMechanismSectionResult(section);
// Call
TestDelegate test = () => new HeightStructuresFailureMechanismSectionResultRow(
result, new HeightStructuresFailureMechanism(), null, ConstructionProperties);
// Assert
string paramName = Assert.Throws(test).ParamName;
Assert.AreEqual("assessmentSection", paramName);
}
[Test]
public void Constructor_ConstructionPropertiesNull_ThrowsArgumentNullException()
{
// Setup
var mocks = new MockRepository();
var assessmentSection = mocks.Stub();
mocks.ReplayAll();
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var result = new HeightStructuresFailureMechanismSectionResult(section);
// Call
TestDelegate test = () => new HeightStructuresFailureMechanismSectionResultRow(
result, new HeightStructuresFailureMechanism(), assessmentSection, null);
// Assert
var exception = Assert.Throws(test);
Assert.AreEqual("constructionProperties", exception.ParamName);
mocks.VerifyAll();
}
[Test]
public void Constructor_WithParameters_ExpectedValues()
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
mocks.ReplayAll();
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var result = new HeightStructuresFailureMechanismSectionResult(section)
{
Calculation = CreateCalculationWithOutput()
};
using (new AssemblyToolCalculatorFactoryConfig())
{
// Call
var row = new HeightStructuresFailureMechanismSectionResultRow(
result, failureMechanism, assessmentSection, ConstructionProperties);
// Assert
Assert.IsInstanceOf>(row);
Assert.AreEqual(result.SimpleAssessmentResult, row.SimpleAssessmentResult);
Assert.AreEqual(result.DetailedAssessmentResult, row.DetailedAssessmentResult);
Assert.AreEqual(result.TailorMadeAssessmentResult, row.TailorMadeAssessmentResult);
Assert.AreEqual(result.TailorMadeAssessmentProbability, row.TailorMadeAssessmentProbability);
Assert.AreEqual(result.UseManualAssemblyProbability, row.UseManualAssemblyProbability);
Assert.AreEqual(result.ManualAssemblyProbability, row.ManualAssemblyProbability);
TestHelper.AssertTypeConverter(
nameof(HeightStructuresFailureMechanismSectionResultRow.DetailedAssessmentProbability));
TestHelper.AssertTypeConverter(
nameof(HeightStructuresFailureMechanismSectionResultRow.TailorMadeAssessmentProbability));
TestHelper.AssertTypeConverter(
nameof(HeightStructuresFailureMechanismSectionResultRow.ManualAssemblyProbability));
IDictionary columnStateDefinitions = row.ColumnStateDefinitions;
Assert.AreEqual(11, columnStateDefinitions.Count);
FailureMechanismSectionResultRowTestHelper.AssertColumnStateDefinition(columnStateDefinitions, ConstructionProperties.SimpleAssessmentResultIndex);
FailureMechanismSectionResultRowTestHelper.AssertColumnStateDefinition(columnStateDefinitions, ConstructionProperties.DetailedAssessmentResultIndex);
FailureMechanismSectionResultRowTestHelper.AssertColumnStateDefinition(columnStateDefinitions, ConstructionProperties.DetailedAssessmentProbabilityIndex);
FailureMechanismSectionResultRowTestHelper.AssertColumnStateDefinition(columnStateDefinitions, ConstructionProperties.TailorMadeAssessmentResultIndex);
FailureMechanismSectionResultRowTestHelper.AssertColumnStateDefinition(columnStateDefinitions, ConstructionProperties.TailorMadeAssessmentProbabilityIndex);
FailureMechanismSectionResultRowTestHelper.AssertColumnStateDefinition(columnStateDefinitions, ConstructionProperties.SimpleAssemblyCategoryGroupIndex);
FailureMechanismSectionResultRowTestHelper.AssertColumnStateDefinition(columnStateDefinitions, ConstructionProperties.DetailedAssemblyCategoryGroupIndex);
FailureMechanismSectionResultRowTestHelper.AssertColumnStateDefinition(columnStateDefinitions, ConstructionProperties.TailorMadeAssemblyCategoryGroupIndex);
FailureMechanismSectionResultRowTestHelper.AssertColumnStateDefinition(columnStateDefinitions, ConstructionProperties.CombinedAssemblyCategoryGroupIndex);
FailureMechanismSectionResultRowTestHelper.AssertColumnStateDefinition(columnStateDefinitions, ConstructionProperties.CombinedAssemblyProbabilityIndex);
FailureMechanismSectionResultRowTestHelper.AssertColumnStateDefinition(columnStateDefinitions, ConstructionProperties.ManualAssemblyProbabilityIndex);
mocks.VerifyAll();
}
}
[Test]
public void UseManualAssemblyProbability_SetNewValue_NotifyObserversAndPropertyChanged()
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
var observer = mocks.StrictMock();
observer.Expect(o => o.UpdateObserver());
mocks.ReplayAll();
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var result = new HeightStructuresFailureMechanismSectionResult(section);
result.Attach(observer);
using (new AssemblyToolCalculatorFactoryConfig())
{
var row = new HeightStructuresFailureMechanismSectionResultRow(
result, failureMechanism, assessmentSection, ConstructionProperties);
bool originalValue = result.UseManualAssemblyProbability;
bool newValue = !originalValue;
// Call
row.UseManualAssemblyProbability = newValue;
// Assert
Assert.AreEqual(newValue, result.UseManualAssemblyProbability);
mocks.VerifyAll();
}
}
[Test]
[TestCase(0)]
[TestCase(1)]
[TestCase(0.5)]
[TestCase(1e-6)]
[TestCase(double.NaN)]
public void ManualAssemblyProbability_ValidValue_NotifyObserversAndPropertyChanged(double value)
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
var observer = mocks.StrictMock();
observer.Expect(o => o.UpdateObserver());
mocks.ReplayAll();
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var result = new HeightStructuresFailureMechanismSectionResult(section);
result.Attach(observer);
using (new AssemblyToolCalculatorFactoryConfig())
{
var row = new HeightStructuresFailureMechanismSectionResultRow(
result, failureMechanism, assessmentSection, ConstructionProperties);
// Call
row.ManualAssemblyProbability = value;
// Assert
Assert.AreEqual(value, row.ManualAssemblyProbability);
mocks.VerifyAll();
}
}
[Test]
[SetCulture("nl-NL")]
[TestCase(-20)]
[TestCase(-1e-6)]
[TestCase(1 + 1e-6)]
[TestCase(12)]
public void ManualAssemblyProbability_InvalidValue_ThrowsArgumentOutOfRangeException(double value)
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
mocks.ReplayAll();
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var result = new HeightStructuresFailureMechanismSectionResult(section);
using (new AssemblyToolCalculatorFactoryConfig())
{
var row = new HeightStructuresFailureMechanismSectionResultRow(
result, failureMechanism, assessmentSection, ConstructionProperties);
// Call
TestDelegate test = () => row.ManualAssemblyProbability = value;
// Assert
const string expectedMessage = "De waarde voor de faalkans moet in het bereik [0,0, 1,0] liggen.";
TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage);
mocks.VerifyAll();
}
}
[Test]
public void GivenRowWithoutAssemblyErrors_WhenUpdatingAndAssemblyThrowsException_ThenAssemblyGroupSetToNone()
{
// Given
var random = new Random(39);
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
mocks.ReplayAll();
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var result = new HeightStructuresFailureMechanismSectionResult(section);
using (new AssemblyToolCalculatorFactoryConfig())
{
var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance;
FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
calculator.SimpleAssessmentAssemblyOutput = new FailureMechanismSectionAssembly(
random.NextDouble(),
random.NextEnumValue());
calculator.DetailedAssessmentAssemblyOutput = new FailureMechanismSectionAssembly(
random.NextDouble(),
random.NextEnumValue());
calculator.TailorMadeAssessmentAssemblyOutput = new FailureMechanismSectionAssembly(
random.NextDouble(),
random.NextEnumValue());
calculator.CombinedAssemblyOutput = new FailureMechanismSectionAssembly(
random.NextDouble(),
random.NextEnumValue());
var row = new HeightStructuresFailureMechanismSectionResultRow(result, failureMechanism, assessmentSection,
ConstructionProperties);
// Precondition
Assert.AreEqual(FailureMechanismSectionResultRowHelper.GetCategoryGroupDisplayname(calculator.SimpleAssessmentAssemblyOutput.Group),
row.SimpleAssemblyCategoryGroup);
Assert.AreEqual(FailureMechanismSectionResultRowHelper.GetCategoryGroupDisplayname(calculator.DetailedAssessmentAssemblyOutput.Group),
row.DetailedAssemblyCategoryGroup);
Assert.AreEqual(FailureMechanismSectionResultRowHelper.GetCategoryGroupDisplayname(calculator.TailorMadeAssessmentAssemblyOutput.Group),
row.TailorMadeAssemblyCategoryGroup);
Assert.AreEqual(FailureMechanismSectionResultRowHelper.GetCategoryGroupDisplayname(calculator.CombinedAssemblyOutput.Group),
row.CombinedAssemblyCategoryGroup);
Assert.AreEqual(calculator.CombinedAssemblyOutput.Probability, row.CombinedAssemblyProbability);
// When
calculator.ThrowExceptionOnCalculate = true;
row.SimpleAssessmentResult = SimpleAssessmentResultType.AssessFurther;
// Then
Assert.AreEqual(FailureMechanismSectionResultRowHelper.GetCategoryGroupDisplayname(FailureMechanismSectionAssemblyCategoryGroup.None),
row.SimpleAssemblyCategoryGroup);
Assert.AreEqual(FailureMechanismSectionResultRowHelper.GetCategoryGroupDisplayname(FailureMechanismSectionAssemblyCategoryGroup.None),
row.DetailedAssemblyCategoryGroup);
Assert.AreEqual(FailureMechanismSectionResultRowHelper.GetCategoryGroupDisplayname(FailureMechanismSectionAssemblyCategoryGroup.None),
row.TailorMadeAssemblyCategoryGroup);
Assert.AreEqual(FailureMechanismSectionResultRowHelper.GetCategoryGroupDisplayname(FailureMechanismSectionAssemblyCategoryGroup.None),
row.CombinedAssemblyCategoryGroup);
Assert.IsNaN(row.CombinedAssemblyProbability);
mocks.VerifyAll();
}
}
[Test]
public void GivenRowWithAssemblyErrors_WhenUpdatingAndAssemblyDoesNotThrowException_ExpectedColumnStates()
{
// Given
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
mocks.ReplayAll();
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var result = new HeightStructuresFailureMechanismSectionResult(section);
using (new AssemblyToolCalculatorFactoryConfig())
{
var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance;
FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
calculator.ThrowExceptionOnCalculate = true;
var row = new HeightStructuresFailureMechanismSectionResultRow(result, failureMechanism, assessmentSection,
ConstructionProperties);
// Precondition
IDictionary columnStateDefinitions = row.ColumnStateDefinitions;
const string expectedErrorText = "Message";
Assert.AreEqual(expectedErrorText, columnStateDefinitions[ConstructionProperties.SimpleAssemblyCategoryGroupIndex].ErrorText);
Assert.AreEqual(expectedErrorText, columnStateDefinitions[ConstructionProperties.DetailedAssemblyCategoryGroupIndex].ErrorText);
Assert.AreEqual(expectedErrorText, columnStateDefinitions[ConstructionProperties.TailorMadeAssemblyCategoryGroupIndex].ErrorText);
Assert.AreEqual(expectedErrorText, columnStateDefinitions[ConstructionProperties.CombinedAssemblyCategoryGroupIndex].ErrorText);
Assert.AreEqual(expectedErrorText, columnStateDefinitions[ConstructionProperties.CombinedAssemblyProbabilityIndex].ErrorText);
// When
calculator.ThrowExceptionOnCalculate = false;
row.SimpleAssessmentResult = SimpleAssessmentResultType.AssessFurther;
// Then
Assert.AreEqual(string.Empty, columnStateDefinitions[ConstructionProperties.SimpleAssemblyCategoryGroupIndex].ErrorText);
Assert.AreEqual(string.Empty, columnStateDefinitions[ConstructionProperties.DetailedAssemblyCategoryGroupIndex].ErrorText);
Assert.AreEqual(string.Empty, columnStateDefinitions[ConstructionProperties.TailorMadeAssemblyCategoryGroupIndex].ErrorText);
Assert.AreEqual(string.Empty, columnStateDefinitions[ConstructionProperties.CombinedAssemblyCategoryGroupIndex].ErrorText);
Assert.AreEqual(string.Empty, columnStateDefinitions[ConstructionProperties.CombinedAssemblyProbabilityIndex].ErrorText);
mocks.VerifyAll();
}
}
private static TestHeightStructuresCalculation CreateCalculationWithOutput()
{
return new TestHeightStructuresCalculation
{
Output = new TestStructuresOutput()
};
}
#region Column States
[Test]
[TestCase(SimpleAssessmentResultType.None, true)]
[TestCase(SimpleAssessmentResultType.NotApplicable, false)]
[TestCase(SimpleAssessmentResultType.AssessFurther, true)]
[TestCase(SimpleAssessmentResultType.ProbabilityNegligible, false)]
public void Constructor_WithSimpleAssessment_ExpectedColumnStates(SimpleAssessmentResultType simpleAssessmentResult,
bool cellsEnabled)
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
mocks.ReplayAll();
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var result = new HeightStructuresFailureMechanismSectionResult(section)
{
SimpleAssessmentResult = simpleAssessmentResult,
Calculation = CreateCalculationWithOutput(),
TailorMadeAssessmentResult = TailorMadeAssessmentProbabilityCalculationResultType.Probability
};
using (new AssemblyToolCalculatorFactoryConfig())
{
// Call
var row = new HeightStructuresFailureMechanismSectionResultRow(
result, failureMechanism, assessmentSection, ConstructionProperties);
// Assert
IDictionary columnStateDefinitions = row.ColumnStateDefinitions;
FailureMechanismSectionResultRowTestHelper.AssertColumnState(columnStateDefinitions[ConstructionProperties.DetailedAssessmentResultIndex],
cellsEnabled);
FailureMechanismSectionResultRowTestHelper.AssertColumnState(columnStateDefinitions[ConstructionProperties.DetailedAssessmentProbabilityIndex],
cellsEnabled,
true);
FailureMechanismSectionResultRowTestHelper.AssertColumnState(columnStateDefinitions[ConstructionProperties.TailorMadeAssessmentResultIndex],
cellsEnabled);
FailureMechanismSectionResultRowTestHelper.AssertColumnState(columnStateDefinitions[ConstructionProperties.TailorMadeAssessmentProbabilityIndex],
cellsEnabled);
mocks.VerifyAll();
}
}
[Test]
[TestCase(DetailedAssessmentProbabilityOnlyResultType.NotAssessed, false)]
[TestCase(DetailedAssessmentProbabilityOnlyResultType.Probability, true)]
public void Constructor_WithDetailedAssessmentResultSet_ExpectedColumnStates(DetailedAssessmentProbabilityOnlyResultType detailedAssessmentResult,
bool cellEnabled)
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
mocks.ReplayAll();
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var result = new HeightStructuresFailureMechanismSectionResult(section)
{
DetailedAssessmentResult = detailedAssessmentResult,
Calculation = CreateCalculationWithOutput()
};
using (new AssemblyToolCalculatorFactoryConfig())
{
// Call
var row = new HeightStructuresFailureMechanismSectionResultRow(
result, failureMechanism, assessmentSection, ConstructionProperties);
// Assert
IDictionary columnStateDefinitions = row.ColumnStateDefinitions;
FailureMechanismSectionResultRowTestHelper.AssertColumnState(columnStateDefinitions[ConstructionProperties.DetailedAssessmentProbabilityIndex],
cellEnabled,
true);
mocks.VerifyAll();
}
}
[Test]
[TestCase(TailorMadeAssessmentProbabilityCalculationResultType.None, false)]
[TestCase(TailorMadeAssessmentProbabilityCalculationResultType.NotAssessed, false)]
[TestCase(TailorMadeAssessmentProbabilityCalculationResultType.ProbabilityNegligible, false)]
[TestCase(TailorMadeAssessmentProbabilityCalculationResultType.Probability, true)]
public void Constructor_WithTailorMadeAssessmentResultSet_ExpectedColumnStates(
TailorMadeAssessmentProbabilityCalculationResultType tailorMadeAssessmentResult,
bool cellEnabled)
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
mocks.ReplayAll();
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var result = new HeightStructuresFailureMechanismSectionResult(section)
{
TailorMadeAssessmentResult = tailorMadeAssessmentResult
};
using (new AssemblyToolCalculatorFactoryConfig())
{
// Call
var row = new HeightStructuresFailureMechanismSectionResultRow(
result, failureMechanism, assessmentSection, ConstructionProperties);
// Assert
IDictionary columnStateDefinitions = row.ColumnStateDefinitions;
FailureMechanismSectionResultRowTestHelper.AssertColumnState(columnStateDefinitions[ConstructionProperties.TailorMadeAssessmentProbabilityIndex],
cellEnabled);
mocks.VerifyAll();
}
}
[Test]
[TestCase(true)]
[TestCase(false)]
public void Constructor_WithUseManualAssemblyCategoryGroupSet_ExpectedColumnStates(bool useManualAssemblyProbability)
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
mocks.ReplayAll();
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var result = new HeightStructuresFailureMechanismSectionResult(section)
{
Calculation = CreateCalculationWithOutput(),
TailorMadeAssessmentResult = TailorMadeAssessmentProbabilityCalculationResultType.Probability,
UseManualAssemblyProbability = useManualAssemblyProbability
};
using (new AssemblyToolCalculatorFactoryConfig())
{
// Call
var row = new HeightStructuresFailureMechanismSectionResultRow(
result, failureMechanism, assessmentSection, ConstructionProperties);
// Assert
IDictionary columnStateDefinitions = row.ColumnStateDefinitions;
FailureMechanismSectionResultRowTestHelper.AssertColumnState(columnStateDefinitions[ConstructionProperties.SimpleAssessmentResultIndex],
!useManualAssemblyProbability);
FailureMechanismSectionResultRowTestHelper.AssertColumnState(columnStateDefinitions[ConstructionProperties.DetailedAssessmentResultIndex],
!useManualAssemblyProbability);
FailureMechanismSectionResultRowTestHelper.AssertColumnState(columnStateDefinitions[ConstructionProperties.DetailedAssessmentProbabilityIndex],
!useManualAssemblyProbability, true);
FailureMechanismSectionResultRowTestHelper.AssertColumnState(columnStateDefinitions[ConstructionProperties.TailorMadeAssessmentResultIndex],
!useManualAssemblyProbability);
FailureMechanismSectionResultRowTestHelper.AssertColumnState(columnStateDefinitions[ConstructionProperties.TailorMadeAssessmentProbabilityIndex],
!useManualAssemblyProbability);
if (useManualAssemblyProbability)
{
FailureMechanismSectionResultRowTestHelper.AssertColumnStateIsDisabled(
columnStateDefinitions[ConstructionProperties.SimpleAssemblyCategoryGroupIndex]);
FailureMechanismSectionResultRowTestHelper.AssertColumnStateIsDisabled(
columnStateDefinitions[ConstructionProperties.DetailedAssemblyCategoryGroupIndex]);
FailureMechanismSectionResultRowTestHelper.AssertColumnStateIsDisabled(
columnStateDefinitions[ConstructionProperties.TailorMadeAssemblyCategoryGroupIndex]);
FailureMechanismSectionResultRowTestHelper.AssertColumnStateIsDisabled(
columnStateDefinitions[ConstructionProperties.CombinedAssemblyCategoryGroupIndex]);
}
FailureMechanismSectionResultRowTestHelper.AssertColumnState(columnStateDefinitions[ConstructionProperties.CombinedAssemblyProbabilityIndex],
!useManualAssemblyProbability, true);
FailureMechanismSectionResultRowTestHelper.AssertColumnState(columnStateDefinitions[ConstructionProperties.ManualAssemblyProbabilityIndex],
useManualAssemblyProbability);
mocks.VerifyAll();
}
}
[Test]
[TestCaseSource(typeof(FailureMechanismSectionResultRowTestHelper), nameof(FailureMechanismSectionResultRowTestHelper.CategoryGroupColorCases))]
public void Constructor_WithAssemblyCategoryGroupsSet_ExpectedColumnStates(FailureMechanismSectionAssemblyCategoryGroup assemblyCategoryGroup,
Color expectedBackgroundColor)
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
mocks.ReplayAll();
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var result = new HeightStructuresFailureMechanismSectionResult(section)
{
TailorMadeAssessmentResult = TailorMadeAssessmentProbabilityCalculationResultType.Probability
};
using (new AssemblyToolCalculatorFactoryConfig())
{
var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance;
FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
var assemblyOutput = new FailureMechanismSectionAssembly(0, assemblyCategoryGroup);
calculator.SimpleAssessmentAssemblyOutput = assemblyOutput;
calculator.DetailedAssessmentAssemblyOutput = assemblyOutput;
calculator.TailorMadeAssessmentAssemblyOutput = assemblyOutput;
calculator.CombinedAssemblyCategoryOutput = assemblyCategoryGroup;
// Call
var row = new HeightStructuresFailureMechanismSectionResultRow(result, failureMechanism, assessmentSection,
ConstructionProperties);
// Assert
IDictionary columnStateDefinitions = row.ColumnStateDefinitions;
FailureMechanismSectionResultRowTestHelper.AssertColumnWithColorState(
columnStateDefinitions[ConstructionProperties.SimpleAssemblyCategoryGroupIndex], expectedBackgroundColor);
FailureMechanismSectionResultRowTestHelper.AssertColumnWithColorState(
columnStateDefinitions[ConstructionProperties.DetailedAssemblyCategoryGroupIndex], expectedBackgroundColor);
FailureMechanismSectionResultRowTestHelper.AssertColumnWithColorState(
columnStateDefinitions[ConstructionProperties.TailorMadeAssemblyCategoryGroupIndex], expectedBackgroundColor);
FailureMechanismSectionResultRowTestHelper.AssertColumnWithColorState(
columnStateDefinitions[ConstructionProperties.CombinedAssemblyCategoryGroupIndex], expectedBackgroundColor);
mocks.VerifyAll();
}
}
[Test]
[TestCase(SimpleAssessmentResultType.None)]
[TestCase(SimpleAssessmentResultType.AssessFurther)]
public void Constructor_SectionResultWithoutCalculation_DetailedAssessmentProbabilityHasErrorText(
SimpleAssessmentResultType simpleAssessmentResult)
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
mocks.ReplayAll();
var sectionResult = new HeightStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
{
SimpleAssessmentResult = simpleAssessmentResult
};
using (new AssemblyToolCalculatorFactoryConfig())
{
// Call
var resultRow = new HeightStructuresFailureMechanismSectionResultRow(
sectionResult, failureMechanism, assessmentSection, ConstructionProperties);
// Assert
Assert.IsNaN(resultRow.DetailedAssessmentProbability);
Assert.AreEqual("Er moet een maatgevende berekening voor dit vak worden geselecteerd.",
resultRow.ColumnStateDefinitions[ConstructionProperties.DetailedAssessmentProbabilityIndex].ErrorText);
mocks.VerifyAll();
}
}
[Test]
[TestCase(SimpleAssessmentResultType.None)]
[TestCase(SimpleAssessmentResultType.AssessFurther)]
public void Constructor_SectionResultAndCalculationNotCalculated_DetailedAssessmentProbabilityHasErrorText(
SimpleAssessmentResultType simpleAssessmentResult)
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
mocks.ReplayAll();
var sectionResult = new HeightStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
{
Calculation = new TestHeightStructuresCalculation(),
SimpleAssessmentResult = simpleAssessmentResult
};
using (new AssemblyToolCalculatorFactoryConfig())
{
// Call
var resultRow = new HeightStructuresFailureMechanismSectionResultRow(
sectionResult, failureMechanism, assessmentSection, ConstructionProperties);
// Assert
Assert.IsNaN(resultRow.DetailedAssessmentProbability);
Assert.AreEqual("De maatgevende berekening voor dit vak moet nog worden uitgevoerd.",
resultRow.ColumnStateDefinitions[ConstructionProperties.DetailedAssessmentProbabilityIndex].ErrorText);
mocks.VerifyAll();
}
}
[Test]
[TestCase(SimpleAssessmentResultType.None)]
[TestCase(SimpleAssessmentResultType.AssessFurther)]
public void Constructor_SectionResultAndFailedCalculation_DetailedAssessmentProbabilityHasErrorText(
SimpleAssessmentResultType simpleAssessmentResult)
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
mocks.ReplayAll();
var calculation = new TestHeightStructuresCalculation
{
Output = new TestStructuresOutput(double.NaN)
};
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var sectionResult = new HeightStructuresFailureMechanismSectionResult(section)
{
Calculation = calculation,
SimpleAssessmentResult = simpleAssessmentResult
};
using (new AssemblyToolCalculatorFactoryConfig())
{
// Call
var resultRow = new HeightStructuresFailureMechanismSectionResultRow(
sectionResult, failureMechanism, assessmentSection, ConstructionProperties);
// Assert
Assert.IsNaN(resultRow.DetailedAssessmentProbability);
Assert.AreEqual("De maatgevende berekening voor dit vak moet een geldige uitkomst hebben.",
resultRow.ColumnStateDefinitions[ConstructionProperties.DetailedAssessmentProbabilityIndex].ErrorText);
mocks.VerifyAll();
}
}
[Test]
public void Constructor_SectionResultAndSuccessfulCalculation_DetailedAssessmentProbabilityNoError()
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
mocks.ReplayAll();
var sectionResult = new HeightStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
{
Calculation = CreateCalculationWithOutput()
};
using (new AssemblyToolCalculatorFactoryConfig())
{
// Call
var resultRow = new HeightStructuresFailureMechanismSectionResultRow(
sectionResult, failureMechanism, assessmentSection, ConstructionProperties);
// Assert
Assert.AreEqual(sectionResult.GetDetailedAssessmentProbability(failureMechanism, assessmentSection), resultRow.DetailedAssessmentProbability);
Assert.IsEmpty(resultRow.ColumnStateDefinitions[ConstructionProperties.DetailedAssessmentProbabilityIndex].ErrorText);
mocks.VerifyAll();
}
}
[Test]
public void Constructor_SectionResultWithManualAssemblyAndNotCalculated_DetailedAssessmentProbabilityNoError()
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
mocks.ReplayAll();
var sectionResult = new HeightStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
{
Calculation = new TestHeightStructuresCalculation(),
UseManualAssemblyProbability = true
};
using (new AssemblyToolCalculatorFactoryConfig())
{
// Call
var resultRow = new HeightStructuresFailureMechanismSectionResultRow(
sectionResult, failureMechanism, assessmentSection, ConstructionProperties);
// Assert
Assert.IsNaN(resultRow.DetailedAssessmentProbability);
Assert.IsEmpty(resultRow.ColumnStateDefinitions[ConstructionProperties.DetailedAssessmentProbabilityIndex].ErrorText);
mocks.VerifyAll();
}
}
[Test]
public void Constructor_SectionResultWithDetailedAssessmentNotAssessedAndNotCalculated_DetailedAssessmentProbabilityNoError()
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
mocks.ReplayAll();
var sectionResult = new HeightStructuresFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
{
Calculation = new TestHeightStructuresCalculation(),
DetailedAssessmentResult = DetailedAssessmentProbabilityOnlyResultType.NotAssessed
};
using (new AssemblyToolCalculatorFactoryConfig())
{
// Call
var resultRow = new HeightStructuresFailureMechanismSectionResultRow(
sectionResult, failureMechanism, assessmentSection, ConstructionProperties);
// Assert
Assert.IsNaN(resultRow.DetailedAssessmentProbability);
Assert.IsEmpty(resultRow.ColumnStateDefinitions[ConstructionProperties.DetailedAssessmentProbabilityIndex].ErrorText);
mocks.VerifyAll();
}
}
[Test]
[TestCaseSource(nameof(SimpleAssessmentResultIsSufficientVariousSectionResults))]
public void Constructor_SectionResultAndAssessmentSimpleAssessmentSufficient_DetailedAssessmentProbabilityNoError(
HeightStructuresFailureMechanismSectionResult sectionResult)
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
mocks.ReplayAll();
using (new AssemblyToolCalculatorFactoryConfig())
{
// Call
var resultRow = new HeightStructuresFailureMechanismSectionResultRow(
sectionResult, failureMechanism, assessmentSection, ConstructionProperties);
// Assert
Assert.AreEqual(sectionResult.GetDetailedAssessmentProbability(failureMechanism, assessmentSection), resultRow.DetailedAssessmentProbability);
Assert.IsEmpty(resultRow.ColumnStateDefinitions[ConstructionProperties.DetailedAssessmentProbabilityIndex].ErrorText);
mocks.VerifyAll();
}
}
private static IEnumerable SimpleAssessmentResultIsSufficientVariousSectionResults()
{
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
yield return new TestCaseData(new HeightStructuresFailureMechanismSectionResult(section)
{
SimpleAssessmentResult = SimpleAssessmentResultType.ProbabilityNegligible
}).SetName("SectionWithoutCalculationAndSimpleAssessmentResultProbabilityNegligible");
yield return new TestCaseData(new HeightStructuresFailureMechanismSectionResult(section)
{
SimpleAssessmentResult = SimpleAssessmentResultType.ProbabilityNegligible,
Calculation = new StructuresCalculation()
}).SetName("SectionWithCalculationNoOutputAndSimpleAssessmentResultProbabilityNegligible");
yield return new TestCaseData(new HeightStructuresFailureMechanismSectionResult(section)
{
SimpleAssessmentResult = SimpleAssessmentResultType.ProbabilityNegligible,
Calculation = new StructuresCalculation
{
Output = new TestStructuresOutput(double.NaN)
}
}).SetName("SectionWithInvalidCalculationOutputAndSimpleAssessmentResultProbabilityNegligible");
yield return new TestCaseData(new HeightStructuresFailureMechanismSectionResult(section)
{
SimpleAssessmentResult = SimpleAssessmentResultType.ProbabilityNegligible,
Calculation = CreateCalculationWithOutput()
}).SetName("SectionWithValidCalculationOutputAndSimpleAssessmentResultProbabilityNegligible");
yield return new TestCaseData(new HeightStructuresFailureMechanismSectionResult(section)
{
SimpleAssessmentResult = SimpleAssessmentResultType.NotApplicable
}).SetName("SectionWithoutCalculationAndSimpleAssessmentResultNotApplicable");
yield return new TestCaseData(new HeightStructuresFailureMechanismSectionResult(section)
{
SimpleAssessmentResult = SimpleAssessmentResultType.NotApplicable,
Calculation = new StructuresCalculation()
}).SetName("SectionWithCalculationNoOutputAndSimpleAssessmentResultNotApplicable");
yield return new TestCaseData(new HeightStructuresFailureMechanismSectionResult(section)
{
SimpleAssessmentResult = SimpleAssessmentResultType.NotApplicable,
Calculation = new StructuresCalculation
{
Output = new TestStructuresOutput(double.NaN)
}
}).SetName("SectionWithInvalidCalculationOutputAndSimpleAssessmentResultNotApplicable");
yield return new TestCaseData(new HeightStructuresFailureMechanismSectionResult(section)
{
SimpleAssessmentResult = SimpleAssessmentResultType.NotApplicable,
Calculation = CreateCalculationWithOutput()
}).SetName("SectionWithValidCalculationOutputAndSimpleAssessmentResultNotApplicable");
}
#endregion
#region Registration
[Test]
public void SimpleAssessmentResult_SetNewValue_NotifyObserversAndPropertyChanged()
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
var observer = mocks.StrictMock();
observer.Expect(o => o.UpdateObserver());
mocks.ReplayAll();
var random = new Random(39);
var newValue = random.NextEnumValue();
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var result = new HeightStructuresFailureMechanismSectionResult(section);
result.Attach(observer);
using (new AssemblyToolCalculatorFactoryConfig())
{
var row = new HeightStructuresFailureMechanismSectionResultRow(result,
failureMechanism,
assessmentSection,
ConstructionProperties);
// Call
row.SimpleAssessmentResult = newValue;
// Assert
Assert.AreEqual(newValue, result.SimpleAssessmentResult);
mocks.VerifyAll();
}
}
[Test]
public void DetailedAssessmentResult_SetNewValue_NotifyObserversAndPropertyChanged()
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
var observer = mocks.StrictMock();
observer.Expect(o => o.UpdateObserver());
mocks.ReplayAll();
var random = new Random(39);
var newValue = random.NextEnumValue();
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var result = new HeightStructuresFailureMechanismSectionResult(section);
result.Attach(observer);
using (new AssemblyToolCalculatorFactoryConfig())
{
var row = new HeightStructuresFailureMechanismSectionResultRow(
result, failureMechanism, assessmentSection, ConstructionProperties);
// Call
row.DetailedAssessmentResult = newValue;
// Assert
Assert.AreEqual(newValue, result.DetailedAssessmentResult);
mocks.VerifyAll();
}
}
[Test]
public void DetailedAssessmentProbability_NoCalculationSet_ReturnNaN()
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
mocks.ReplayAll();
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var sectionResult = new HeightStructuresFailureMechanismSectionResult(section);
// Precondition
Assert.IsNull(sectionResult.Calculation);
using (new AssemblyToolCalculatorFactoryConfig())
{
var resultRow = new HeightStructuresFailureMechanismSectionResultRow(
sectionResult, failureMechanism, assessmentSection, ConstructionProperties);
// Call
double detailedAssessmentProbability = resultRow.DetailedAssessmentProbability;
// Assert
Assert.IsNaN(detailedAssessmentProbability);
mocks.VerifyAll();
}
}
[Test]
[TestCase(CalculationScenarioStatus.Failed)]
[TestCase(CalculationScenarioStatus.NotCalculated)]
public void DetailedAssessmentProbability_CalculationNotDone_ReturnNaN(CalculationScenarioStatus status)
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
mocks.ReplayAll();
var calculation = new StructuresCalculation();
if (status == CalculationScenarioStatus.Failed)
{
calculation.Output = new TestStructuresOutput(double.NaN);
}
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var sectionResult = new HeightStructuresFailureMechanismSectionResult(section)
{
Calculation = calculation
};
using (new AssemblyToolCalculatorFactoryConfig())
{
var resultRow = new HeightStructuresFailureMechanismSectionResultRow(
sectionResult, failureMechanism, assessmentSection, ConstructionProperties);
// Call
double detailedAssessmentProbability = resultRow.DetailedAssessmentProbability;
// Assert
Assert.IsNaN(detailedAssessmentProbability);
mocks.VerifyAll();
}
}
[Test]
public void DetailedAssessmentProbability_CalculationSuccessful_ReturnDetailedAssessmentProbability()
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
mocks.ReplayAll();
var calculation = new StructuresCalculation
{
Output = new TestStructuresOutput(new Random(39).NextDouble())
};
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var sectionResult = new HeightStructuresFailureMechanismSectionResult(section)
{
Calculation = calculation
};
using (new AssemblyToolCalculatorFactoryConfig())
{
var resultRow = new HeightStructuresFailureMechanismSectionResultRow(
sectionResult, failureMechanism, assessmentSection, ConstructionProperties);
// Call
double detailedAssessmentProbability = resultRow.DetailedAssessmentProbability;
// Assert
Assert.AreEqual(sectionResult.GetDetailedAssessmentProbability(failureMechanism, assessmentSection), detailedAssessmentProbability);
mocks.VerifyAll();
}
}
[Test]
public void TailorMadeAssessmentResult_SetNewValue_NotifyObserversAndPropertyChanged()
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
var observer = mocks.StrictMock();
observer.Expect(o => o.UpdateObserver());
mocks.ReplayAll();
var random = new Random(39);
var newValue = random.NextEnumValue();
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var result = new HeightStructuresFailureMechanismSectionResult(section);
result.Attach(observer);
using (new AssemblyToolCalculatorFactoryConfig())
{
var row = new HeightStructuresFailureMechanismSectionResultRow(
result, failureMechanism, assessmentSection, ConstructionProperties);
// Call
row.TailorMadeAssessmentResult = newValue;
// Assert
Assert.AreEqual(newValue, result.TailorMadeAssessmentResult);
mocks.VerifyAll();
}
}
[Test]
[TestCase(0)]
[TestCase(1)]
[TestCase(0.5)]
[TestCase(1e-6)]
[TestCase(double.NaN)]
public void TailorMadeAssessmentProbability_ValidValue_NotifyObserversAndPropertyChanged(double value)
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
var observer = mocks.StrictMock();
observer.Expect(o => o.UpdateObserver());
mocks.ReplayAll();
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var result = new HeightStructuresFailureMechanismSectionResult(section);
result.Attach(observer);
using (new AssemblyToolCalculatorFactoryConfig())
{
var row = new HeightStructuresFailureMechanismSectionResultRow(
result, failureMechanism, assessmentSection, ConstructionProperties);
// Call
row.TailorMadeAssessmentProbability = value;
// Assert
Assert.AreEqual(value, row.TailorMadeAssessmentProbability);
mocks.VerifyAll();
}
}
[Test]
[SetCulture("nl-NL")]
[TestCase(-20)]
[TestCase(-1e-6)]
[TestCase(1 + 1e-6)]
[TestCase(12)]
public void TailorMadeAssessmentProbability_InvalidValue_ThrowsArgumentOutOfRangeException(double value)
{
// Setup
var failureMechanism = new HeightStructuresFailureMechanism();
var mocks = new MockRepository();
IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks);
mocks.ReplayAll();
FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
var result = new HeightStructuresFailureMechanismSectionResult(section);
using (new AssemblyToolCalculatorFactoryConfig())
{
var row = new HeightStructuresFailureMechanismSectionResultRow(
result, failureMechanism, assessmentSection, ConstructionProperties);
// Call
TestDelegate test = () => row.TailorMadeAssessmentProbability = value;
// Assert
const string expectedMessage = "De waarde voor de faalkans moet in het bereik [0,0, 1,0] liggen.";
TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage);
mocks.VerifyAll();
}
}
#endregion
}
}