// 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.Linq;
using Ringtoets.AssemblyTool.Data;
using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly;
namespace Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly
{
///
/// Assessment section assembly calculator stub for testing purposes.
///
public class AssessmentSectionAssemblyCalculatorStub : IAssessmentSectionAssemblyCalculator
{
///
/// Gets the lower norm input when assembling the assessment section with failure mechanisms
/// with probability;
///
public double LowerLimitNormInput { get; private set; }
///
/// Gets the lower norm input when assembling the assessment section with failure mechanisms
/// with probability;
///
public double SignalingNormInput { get; private set; }
///
/// Gets the collection of failure mechanism assembly input when assembling the
/// assessment section with failure mechanisms with probability.
///
public IEnumerable FailureMechanismAssemblyInput { get; private set; }
///
/// Gets the collection of failure mechanism assembly category group input when assembling the
/// assessment section with failure mechanisms without probability.
///
public IEnumerable FailureMechanismAssemblyCategoryGroupInput { get; private set; }
///
/// Gets the failure mechanisms without probability input when assembling the assessment section.
///
public AssessmentSectionAssemblyCategoryGroup FailureMechanismsWithoutProbabilityInput { get; private set; }
///
/// Gets the failure mechanisms with probability input when assembling the assessment section.
///
public AssessmentSectionAssembly FailureMechanismsWithProbabilityInput { get; private set; }
///
/// Gets the combined failure mechanism sections input.
///
public IEnumerable> CombinedFailureMechanismSectionsInput { get; private set; }
///
/// Gets the assessment section length input.
///
public double AssessmentSectionLength { get; private set; }
///
/// Gets or sets the output of the assessment section assembly for failure
/// mechanisms with probability.
///
public AssessmentSectionAssembly AssembleFailureMechanismsAssemblyOutput { get; set; }
///
/// Gets or sets the output of the assessment section assembly category group when assembling failure
/// mechanisms without probability.
///
public AssessmentSectionAssemblyCategoryGroup? AssembleFailureMechanismsAssemblyCategoryGroupOutput { get; set; }
///
/// Gets or sets the output of the assessment section assembly category group
/// when assembling an assessment section.
///
public AssessmentSectionAssemblyCategoryGroup? AssembleAssessmentSectionCategoryGroupOutput { get; set; }
///
/// Gets or sets the output of the combined failure mechanism section assembly.
///
public IEnumerable CombinedFailureMechanismSectionAssemblyOutput { get; set; }
///
/// Sets an indicator whether an exception must be thrown while performing a calculation.
///
public bool ThrowExceptionOnCalculate { private get; set; }
public AssessmentSectionAssembly AssembleFailureMechanisms(IEnumerable input,
double signalingNorm,
double lowerLimitNorm)
{
if (ThrowExceptionOnCalculate)
{
throw new AssessmentSectionAssemblyCalculatorException("Message", new Exception());
}
FailureMechanismAssemblyInput = input;
LowerLimitNormInput = lowerLimitNorm;
SignalingNormInput = signalingNorm;
return AssembleFailureMechanismsAssemblyOutput ??
new AssessmentSectionAssembly(0.75, AssessmentSectionAssemblyCategoryGroup.D);
}
public AssessmentSectionAssemblyCategoryGroup AssembleFailureMechanisms(IEnumerable input)
{
if (ThrowExceptionOnCalculate)
{
throw new AssessmentSectionAssemblyCalculatorException("Message", new Exception());
}
FailureMechanismAssemblyCategoryGroupInput = input;
if (AssembleFailureMechanismsAssemblyCategoryGroupOutput == null)
{
AssembleFailureMechanismsAssemblyCategoryGroupOutput = AssessmentSectionAssemblyCategoryGroup.D;
}
return AssembleFailureMechanismsAssemblyCategoryGroupOutput.Value;
}
public AssessmentSectionAssemblyCategoryGroup AssembleAssessmentSection(AssessmentSectionAssemblyCategoryGroup failureMechanismsWithoutProbability,
AssessmentSectionAssembly failureMechanismsWithProbability)
{
if (ThrowExceptionOnCalculate)
{
throw new AssessmentSectionAssemblyCalculatorException("Message", new Exception());
}
FailureMechanismsWithoutProbabilityInput = failureMechanismsWithoutProbability;
FailureMechanismsWithProbabilityInput = failureMechanismsWithProbability;
if (AssembleAssessmentSectionCategoryGroupOutput == null)
{
AssembleAssessmentSectionCategoryGroupOutput = AssessmentSectionAssemblyCategoryGroup.C;
}
return AssembleAssessmentSectionCategoryGroupOutput.Value;
}
public IEnumerable AssembleCombinedFailureMechanismSections(IEnumerable> input,
double assessmentSectionLength)
{
if (ThrowExceptionOnCalculate)
{
throw new AssessmentSectionAssemblyCalculatorException("Message", new Exception());
}
CombinedFailureMechanismSectionsInput = input;
AssessmentSectionLength = assessmentSectionLength;
return CombinedFailureMechanismSectionAssemblyOutput ?? (CombinedFailureMechanismSectionAssemblyOutput = new[]
{
new CombinedFailureMechanismSectionAssembly(
new CombinedAssemblyFailureMechanismSection(0, 1, FailureMechanismSectionAssemblyCategoryGroup.IIIv),
input.Select(failureMechanism => FailureMechanismSectionAssemblyCategoryGroup.VIv).ToArray())
});
}
}
}