public void ReadNonAdoptableFailureMechanismSectionResultEntity_ParameterValues_SectionResultWithParameterValues() { // Setup var random = new Random(21); bool isRelevant = random.NextBoolean(); var initialFailureMechanismResultType = random.NextEnumValue <NonAdoptableInitialFailureMechanismResultType>(); double manualSectionProbability = random.NextDouble(); var furtherAnalysisType = random.NextEnumValue <FailureMechanismSectionResultFurtherAnalysisType>(); double refinedSectionProbability = random.NextDouble(); var entity = new NonAdoptableFailureMechanismSectionResultEntity { IsRelevant = Convert.ToByte(isRelevant), InitialFailureMechanismResultType = Convert.ToByte(initialFailureMechanismResultType), ManualInitialFailureMechanismResultSectionProbability = manualSectionProbability, FurtherAnalysisType = Convert.ToByte(furtherAnalysisType), RefinedSectionProbability = refinedSectionProbability }; var sectionResult = new NonAdoptableFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); // Call entity.Read(sectionResult); // Assert Assert.AreEqual(isRelevant, sectionResult.IsRelevant); Assert.AreEqual(initialFailureMechanismResultType, sectionResult.InitialFailureMechanismResultType); Assert.AreEqual(manualSectionProbability, sectionResult.ManualInitialFailureMechanismResultSectionProbability); Assert.AreEqual(furtherAnalysisType, sectionResult.FurtherAnalysisType); Assert.AreEqual(refinedSectionProbability, sectionResult.RefinedSectionProbability); }
public void CreateNonAdoptableFailureMechanismSectionResult_SectionResultWithValues_ReturnsEntityWithExpectedValues() { // Setup var random = new Random(21); bool isRelevant = random.NextBoolean(); var initialFailureMechanismResultType = random.NextEnumValue <NonAdoptableInitialFailureMechanismResultType>(); double manualSectionProbability = random.NextDouble(); var furtherAnalysisType = random.NextEnumValue <FailureMechanismSectionResultFurtherAnalysisType>(); double refinedSectionProbability = random.NextDouble(); var sectionResult = new NonAdoptableFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) { IsRelevant = isRelevant, InitialFailureMechanismResultType = initialFailureMechanismResultType, ManualInitialFailureMechanismResultSectionProbability = manualSectionProbability, FurtherAnalysisType = furtherAnalysisType, RefinedSectionProbability = refinedSectionProbability }; // Call NonAdoptableFailureMechanismSectionResultEntity entity = sectionResult.Create(); // Assert Assert.AreEqual(Convert.ToByte(isRelevant), entity.IsRelevant); Assert.AreEqual(Convert.ToByte(initialFailureMechanismResultType), entity.InitialFailureMechanismResultType); Assert.AreEqual(manualSectionProbability, entity.ManualInitialFailureMechanismResultSectionProbability); Assert.AreEqual(Convert.ToByte(furtherAnalysisType), entity.FurtherAnalysisType); Assert.AreEqual(refinedSectionProbability, entity.RefinedSectionProbability); }
/// <summary> /// Asserts whether the data of the <see cref="NonAdoptableFailureMechanismSectionResultEntity"/> and /// <see cref="NonAdoptableFailureMechanismSectionResult"/> have equal values. /// </summary> /// <param name="sectionResultEntity">The <see cref="NonAdoptableFailureMechanismSectionResultEntity"/>.</param> /// <param name="sectionResult">The <see cref="NonAdoptableFailureMechanismSectionResult"/>.</param> public static void AssertSectionResult(NonAdoptableFailureMechanismSectionResultEntity sectionResultEntity, NonAdoptableFailureMechanismSectionResult sectionResult) { Assert.AreEqual(Convert.ToBoolean(sectionResultEntity.IsRelevant), sectionResult.IsRelevant); Assert.AreEqual((NonAdoptableInitialFailureMechanismResultType)sectionResultEntity.InitialFailureMechanismResultType, sectionResult.InitialFailureMechanismResultType); Assert.AreEqual(sectionResultEntity.ManualInitialFailureMechanismResultSectionProbability.ToNullAsNaN(), sectionResult.ManualInitialFailureMechanismResultSectionProbability); Assert.AreEqual((FailureMechanismSectionResultFurtherAnalysisType)sectionResultEntity.FurtherAnalysisType, sectionResult.FurtherAnalysisType); Assert.AreEqual(sectionResultEntity.RefinedSectionProbability.ToNullAsNaN(), sectionResult.RefinedSectionProbability); }
/// <summary> /// Sets random section results for a <see cref="NonAdoptableFailureMechanismSectionResultEntity"/>. /// </summary> /// <param name="sectionResult">The failure mechanism section result to set.</param> public static void SetSectionResult(NonAdoptableFailureMechanismSectionResultEntity sectionResult) { var random = new Random(21); sectionResult.IsRelevant = Convert.ToByte(random.NextBoolean()); sectionResult.InitialFailureMechanismResultType = Convert.ToByte(random.NextEnumValue <NonAdoptableInitialFailureMechanismResultType>()); sectionResult.ManualInitialFailureMechanismResultSectionProbability = random.NextDouble(); sectionResult.FurtherAnalysisType = Convert.ToByte(random.NextEnumValue <FailureMechanismSectionResultFurtherAnalysisType>()); sectionResult.RefinedSectionProbability = random.NextDouble(); }
private static void AddEntitiesForSectionResults( IEnumerable <NonAdoptableFailureMechanismSectionResult> sectionResults, PersistenceRegistry registry) { foreach (NonAdoptableFailureMechanismSectionResult failureMechanismSectionResult in sectionResults) { NonAdoptableFailureMechanismSectionResultEntity sectionResultEntity = failureMechanismSectionResult.Create(); FailureMechanismSectionEntity section = registry.Get(failureMechanismSectionResult.Section); section.NonAdoptableFailureMechanismSectionResultEntities.Add(sectionResultEntity); } }
public void ReadNonAdoptableFailureMechanismSectionResultEntity_EntityWithNullValues_SectionResultWithNaNValues() { // Setup var entity = new NonAdoptableFailureMechanismSectionResultEntity(); var sectionResult = new NonAdoptableFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()); // Call entity.Read(sectionResult); // Assert Assert.IsNaN(sectionResult.ManualInitialFailureMechanismResultSectionProbability); Assert.IsNaN(sectionResult.RefinedSectionProbability); }
public void ReadNonAdoptableFailureMechanismSectionResultEntity_SectionResultNull_ThrowsArgumentNullException() { // Setup var entity = new NonAdoptableFailureMechanismSectionResultEntity(); // Call void Call() => entity.Read(null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("sectionResult", exception.ParamName); }
/// <summary> /// Creates an instance of <see cref="NonAdoptableFailureMechanismSectionResultEntity"/> /// based on the information of the <see cref="NonAdoptableFailureMechanismSectionResult"/>. /// </summary> /// <param name="result">The result to create a database entity for.</param> /// <returns>A <see cref="NonAdoptableFailureMechanismSectionResultEntity"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="result"/> is <c>null</c>.</exception> internal static NonAdoptableFailureMechanismSectionResultEntity Create(this NonAdoptableFailureMechanismSectionResult result) { if (result == null) { throw new ArgumentNullException(nameof(result)); } var sectionResultEntity = new NonAdoptableFailureMechanismSectionResultEntity { InitialFailureMechanismResultType = Convert.ToByte(result.InitialFailureMechanismResultType) }; sectionResultEntity.SetCommonFailureMechanismSectionResultProperties(result); return(sectionResultEntity); }
public void CreateNonAdoptableFailureMechanismSectionResult_SectionResultWithNaNValues_ReturnsEntityWithExpectedResults() { // Setup var sectionResult = new NonAdoptableFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) { ManualInitialFailureMechanismResultSectionProbability = double.NaN, RefinedSectionProbability = double.NaN }; // Call NonAdoptableFailureMechanismSectionResultEntity entity = sectionResult.Create(); // Assert Assert.IsNull(entity.ManualInitialFailureMechanismResultSectionProbability); Assert.IsNull(entity.RefinedSectionProbability); }
/// <summary> /// Reads the <see cref="NonAdoptableFailureMechanismSectionResultEntity"/> and use the information /// to update a <see cref="NonAdoptableFailureMechanismSectionResult"/>. /// </summary> /// <param name="entity">The <see cref="NonAdoptableFailureMechanismSectionResultEntity"/> used to update /// the <paramref name="sectionResult"/>.</param> /// <param name="sectionResult">The target of the read operation.</param> /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception> internal static void Read(this NonAdoptableFailureMechanismSectionResultEntity entity, NonAdoptableFailureMechanismSectionResult sectionResult) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (sectionResult == null) { throw new ArgumentNullException(nameof(sectionResult)); } sectionResult.InitialFailureMechanismResultType = (NonAdoptableInitialFailureMechanismResultType)entity.InitialFailureMechanismResultType; sectionResult.SetCommonFailureMechanismSectionResultProperties(entity); }