// Copyright (C) Stichting Deltares 2021. All rights reserved. // // This file is part of Riskeer. // // Riskeer 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 Assembly.Kernel.Exceptions; using Assembly.Kernel.Interfaces; using Assembly.Kernel.Model; using Assembly.Kernel.Model.Categories; namespace Riskeer.AssemblyTool.KernelWrapper.TestUtil.Kernels.Assembly { /// /// Assessment section assembly kernel stub for testing purposes. /// public class AssessmentSectionAssemblyKernelStub : IAssessmentGradeAssembler { /// /// Gets the collection of used as an input parameter for assembly methods. /// public IEnumerable FailureMechanismProbabilities { get; private set; } /// /// Gets the collection of assessment section categories. /// public CategoriesList Categories { get; private set; } /// /// Gets the assembly probability. /// public Probability AssemblyProbabilityInput { get; private set; } /// /// Gets a value indicating whether an assembly is partial. /// public bool? PartialAssembly { get; private set; } /// /// Gets a value indicating whether a probability calculation was called or not. /// public bool ProbabilityCalculated { get; private set; } /// /// Gets a value indicating whether an assembly group calculation was called or not. /// public bool AssemblyGroupCalculated { get; private set; } /// /// Sets an indicator whether an must be thrown while performing a calculation. /// public bool ThrowExceptionOnCalculate { private get; set; } /// /// Sets an indicator whether an must be thrown while performing a calculation. /// public bool ThrowAssemblyExceptionOnCalculate { private get; set; } /// /// Sets the assembly probability of an assessment section. /// public Probability AssemblyProbability { private get; set; } /// /// Sets the assembly group of an assessment section. /// public EAssessmentGrade AssemblyGroup { private get; set; } public Probability CalculateAssessmentSectionFailureProbabilityBoi2A1(IEnumerable failureMechanismProbabilities, bool partialAssembly) { ThrowException(); ProbabilityCalculated = true; FailureMechanismProbabilities = failureMechanismProbabilities; PartialAssembly = partialAssembly; return AssemblyProbability; } public EAssessmentGrade DetermineAssessmentGradeBoi2B1(Probability failureProbability, CategoriesList categories) { ThrowException(); AssemblyGroupCalculated = true; AssemblyProbabilityInput = failureProbability; Categories = categories; return AssemblyGroup; } private void ThrowException() { if (ThrowExceptionOnCalculate) { throw new Exception("Message", new Exception()); } if (ThrowAssemblyExceptionOnCalculate) { throw new AssemblyException("entity", EAssemblyErrors.InvalidCategoryLimits); } } } }