private void AssertAreEqualGradeCategories(EAssessmentGrade expectedCategory, double expectedLowerLimit, double expectedUpperLimit, AssessmentSectionCategory assessmentSectionCategory) { Assert.AreEqual(expectedCategory, assessmentSectionCategory.Category); Assert.AreEqual(expectedLowerLimit, assessmentSectionCategory.LowerLimit, 1e-15); Assert.AreEqual(expectedUpperLimit, assessmentSectionCategory.UpperLimit, 1e-15); }
public void ConstructorPassesArguments() { Probability prob = new Probability(0.000012687423); EAssessmentGrade grade = EAssessmentGrade.B; var result = new AssessmentSectionResult(prob, grade); Assert.AreEqual(prob, result.FailureProbability); Assert.AreEqual(grade, result.Category); }
public void CreateAssessmentSectionAssemblyGroup_WithValidAssessmentGrade_ReturnsExpectedAssessmentSectionAssemblyGroup( EAssessmentGrade assessmentGrade, AssessmentSectionAssemblyGroup expectedAssemblyGroup) { // Call AssessmentSectionAssemblyGroup result = AssessmentSectionAssemblyGroupCreator.CreateAssessmentSectionAssemblyGroup(assessmentGrade); // Assert Assert.AreEqual(expectedAssemblyGroup, result); }
public AssessmentSectionAssemblyResultWrapper AssembleAssessmentSection(IEnumerable <double> failureMechanismProbabilities, double maximumAllowableFloodingProbability, double signalFloodingProbability) { if (failureMechanismProbabilities == null) { throw new ArgumentNullException(nameof(failureMechanismProbabilities)); } try { ICategoryLimitsCalculator categoryLimitsKernel = factory.CreateAssemblyGroupsKernel(); CategoriesList <AssessmentSectionCategory> assessmentSectionCategories = categoryLimitsKernel.CalculateAssessmentSectionCategoryLimitsBoi21( new AssessmentSection(AssemblyCalculatorInputCreator.CreateProbability(signalFloodingProbability), AssemblyCalculatorInputCreator.CreateProbability(maximumAllowableFloodingProbability))); IAssessmentGradeAssembler assessmentSectionAssemblyKernel = factory.CreateAssessmentSectionAssemblyKernel(); IEnumerable <Probability> probabilities = failureMechanismProbabilities.Select(AssemblyCalculatorInputCreator.CreateProbability) .ToArray(); Probability assemblyProbability = assessmentSectionAssemblyKernel.CalculateAssessmentSectionFailureProbabilityBoi2A1(probabilities, false); EAssessmentGrade assemblyCategory = assessmentSectionAssemblyKernel.DetermineAssessmentGradeBoi2B1(assemblyProbability, assessmentSectionCategories); return(new AssessmentSectionAssemblyResultWrapper( new AssessmentSectionAssemblyResult(assemblyProbability, AssessmentSectionAssemblyGroupCreator.CreateAssessmentSectionAssemblyGroup(assemblyCategory)), AssemblyMethod.BOI2A1, AssemblyMethod.BOI2B1)); } catch (AssemblyException e) { throw new AssessmentSectionAssemblyCalculatorException(AssemblyErrorMessageCreator.CreateErrorMessage(e.Errors), e); } catch (Exception e) { throw new AssessmentSectionAssemblyCalculatorException(AssemblyErrorMessageCreator.CreateGenericErrorMessage(), e); } }
/// <summary> /// Constructor of AssessmentSectionResult /// </summary> /// <param name="failureProbability">The estimated probability of flooding of the assessment section</param> /// <param name="grade">The grade associated with the probability of flooding</param> /// <exception cref="AssemblyException">Thrown when the specified probability is less than 0.0 or greater than 1.0</exception> public AssessmentSectionResult(Probability failureProbability, EAssessmentGrade grade) { Category = grade; FailureProbability = failureProbability; }
public void Wbi2B1FailureProbabilityTests(double prob1, double prob2, double expectedProb, EAssessmentGrade expectedGrade) { var categories = categoriesCalculator.CalculateAssessmentSectionCategoryLimitsWbi21(assessmentSection); var failureMechanismProbabilities = new[] { (Probability)prob1, (Probability)prob2, }; var result = assembler.AssembleAssessmentSectionWbi2B1(failureMechanismProbabilities, categories, false); Assert.NotNull(result.FailureProbability); Assert.AreEqual(expectedProb, result.FailureProbability, 10); Assert.AreEqual(expectedGrade, result.Category); }
/// <summary> /// Creates an <see cref="AssessmentSectionAssemblyGroup"/> based on <paramref name="assessmentGrade"/>. /// </summary> /// <param name="assessmentGrade">The <see cref="EAssessmentGrade"/> to convert.</param> /// <returns>A <see cref="AssessmentSectionAssemblyGroup"/> based on <paramref name="assessmentGrade"/>.</returns> /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="assessmentGrade"/> /// is an invalid value.</exception> /// <exception cref="NotSupportedException">Thrown when <paramref name="assessmentGrade"/> /// is a valid value, but unsupported.</exception> public static AssessmentSectionAssemblyGroup CreateAssessmentSectionAssemblyGroup(EAssessmentGrade assessmentGrade) { if (!Enum.IsDefined(typeof(EAssessmentGrade), assessmentGrade)) { throw new InvalidEnumArgumentException(nameof(assessmentGrade), (int)assessmentGrade, typeof(EAssessmentGrade)); } switch (assessmentGrade) { case EAssessmentGrade.APlus: return(AssessmentSectionAssemblyGroup.APlus); case EAssessmentGrade.A: return(AssessmentSectionAssemblyGroup.A); case EAssessmentGrade.B: return(AssessmentSectionAssemblyGroup.B); case EAssessmentGrade.C: return(AssessmentSectionAssemblyGroup.C); case EAssessmentGrade.D: return(AssessmentSectionAssemblyGroup.D); default: throw new NotSupportedException(); } }
private static AssessmentSectionAssemblyGroup GetAssessmentSectionAssemblyGroup(EAssessmentGrade group) { switch (group) { case EAssessmentGrade.APlus: return(AssessmentSectionAssemblyGroup.APlus); case EAssessmentGrade.A: return(AssessmentSectionAssemblyGroup.A); case EAssessmentGrade.B: return(AssessmentSectionAssemblyGroup.B); case EAssessmentGrade.C: return(AssessmentSectionAssemblyGroup.C); case EAssessmentGrade.D: return(AssessmentSectionAssemblyGroup.D); default: throw new NotSupportedException(); } }