public void CreateNonAdoptableWithProfileProbabilityFailureMechanismSectionResult_WithDifferentResults_ReturnsEntityWithExpectedResults()
        {
            // Setup
            var    random     = new Random(21);
            bool   isRelevant = random.NextBoolean();
            var    initialFailureMechanismResultType = random.NextEnumValue <NonAdoptableInitialFailureMechanismResultType>();
            double manualProfileProbability          = random.NextDouble();
            double manualSectionProbability          = random.NextDouble();
            var    furtherAnalysisType       = random.NextEnumValue <FailureMechanismSectionResultFurtherAnalysisType>();
            double refinedProfileProbability = random.NextDouble();
            double refinedSectionProbability = random.NextDouble();

            var sectionResult = new NonAdoptableWithProfileProbabilityFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
            {
                IsRelevant = isRelevant,
                InitialFailureMechanismResultType = initialFailureMechanismResultType,
                ManualInitialFailureMechanismResultProfileProbability = manualProfileProbability,
                ManualInitialFailureMechanismResultSectionProbability = manualSectionProbability,
                FurtherAnalysisType       = furtherAnalysisType,
                RefinedProfileProbability = refinedProfileProbability,
                RefinedSectionProbability = refinedSectionProbability
            };

            // Call
            NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity entity = sectionResult.Create();

            // Assert
            Assert.AreEqual(Convert.ToByte(isRelevant), entity.IsRelevant);
            Assert.AreEqual(Convert.ToByte(initialFailureMechanismResultType), entity.InitialFailureMechanismResultType);
            Assert.AreEqual(manualProfileProbability, entity.ManualInitialFailureMechanismResultProfileProbability);
            Assert.AreEqual(manualSectionProbability, entity.ManualInitialFailureMechanismResultSectionProbability);
            Assert.AreEqual(Convert.ToByte(furtherAnalysisType), entity.FurtherAnalysisType);
            Assert.AreEqual(refinedProfileProbability, entity.RefinedProfileProbability);
            Assert.AreEqual(refinedSectionProbability, entity.RefinedSectionProbability);
        }
Beispiel #2
0
        /// <summary>
        /// Asserts whether the data of the <see cref="NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity"/> and
        /// <see cref="NonAdoptableWithProfileProbabilityFailureMechanismSectionResult"/> have equal values.
        /// </summary>
        /// <param name="sectionResultEntity">The <see cref="NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity"/>.</param>
        /// <param name="sectionResult">The <see cref="NonAdoptableWithProfileProbabilityFailureMechanismSectionResult"/>.</param>
        public static void AssertSectionResult(NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity sectionResultEntity,
                                               NonAdoptableWithProfileProbabilityFailureMechanismSectionResult 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);

            Assert.AreEqual(sectionResultEntity.ManualInitialFailureMechanismResultProfileProbability.ToNullAsNaN(), sectionResult.ManualInitialFailureMechanismResultProfileProbability);
            Assert.AreEqual(sectionResultEntity.RefinedProfileProbability.ToNullAsNaN(), sectionResult.RefinedProfileProbability);
        }
Beispiel #3
0
        public void ReadNonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity_SectionResultNull_ThrowsArgumentNullException()
        {
            // Setup
            var entity = new NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity();

            // Call
            void Call() => entity.Read(null);

            // Assert
            string paramName = Assert.Throws <ArgumentNullException>(Call).ParamName;

            Assert.AreEqual("sectionResult", paramName);
        }
Beispiel #4
0
        /// <summary>
        /// Sets random section results for a <see cref="NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity"/>.
        /// </summary>
        /// <param name="sectionResult">The failure mechanism section result to set.</param>
        public static void SetSectionResult(NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity 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();

            sectionResult.ManualInitialFailureMechanismResultProfileProbability = random.NextDouble();
            sectionResult.RefinedProfileProbability = random.NextDouble();
        }
Beispiel #5
0
        public void ReadNonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity_EntityWithNullValues_SectionResultWithNaNValues()
        {
            // Setup
            var entity        = new NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity();
            var sectionResult = new NonAdoptableWithProfileProbabilityFailureMechanismSectionResult(
                FailureMechanismSectionTestFactory.CreateFailureMechanismSection());

            // Call
            entity.Read(sectionResult);

            // Assert
            Assert.IsNaN(sectionResult.ManualInitialFailureMechanismResultProfileProbability);
            Assert.IsNaN(sectionResult.ManualInitialFailureMechanismResultSectionProbability);
            Assert.IsNaN(sectionResult.RefinedProfileProbability);
            Assert.IsNaN(sectionResult.RefinedSectionProbability);
        }
        /// <summary>
        /// Creates an instance of <see cref="NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity"/>
        /// based on the information of the <see cref="NonAdoptableWithProfileProbabilityFailureMechanismSectionResult"/>.
        /// </summary>
        /// <param name="result">The result to create a database entity for.</param>
        /// <returns>A <see cref="NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="result"/> is <c>null</c>.</exception>
        internal static NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity Create(
            this NonAdoptableWithProfileProbabilityFailureMechanismSectionResult result)
        {
            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }

            var sectionResultEntity = new NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity
            {
                InitialFailureMechanismResultType = Convert.ToByte(result.InitialFailureMechanismResultType),
                ManualInitialFailureMechanismResultProfileProbability = result.ManualInitialFailureMechanismResultProfileProbability.ToNaNAsNull(),
                RefinedProfileProbability = result.RefinedProfileProbability.ToNaNAsNull()
            };

            sectionResultEntity.SetCommonFailureMechanismSectionResultProperties(result);
            return(sectionResultEntity);
        }
        /// <summary>
        /// Reads the <see cref="NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity"/> and use the information
        /// to update an <see cref="NonAdoptableWithProfileProbabilityFailureMechanismSectionResult"/>.
        /// </summary>
        /// <param name="entity">The <see cref="NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity"/> used to update
        /// the <paramref name="sectionResult"/>.</param>
        /// <param name="sectionResult">The target of the read operation.</param>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        internal static void Read(this NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity entity,
                                  NonAdoptableWithProfileProbabilityFailureMechanismSectionResult sectionResult)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            if (sectionResult == null)
            {
                throw new ArgumentNullException(nameof(sectionResult));
            }

            sectionResult.InitialFailureMechanismResultType = (NonAdoptableInitialFailureMechanismResultType)entity.InitialFailureMechanismResultType;
            sectionResult.ManualInitialFailureMechanismResultProfileProbability = entity.ManualInitialFailureMechanismResultProfileProbability.ToNullAsNaN();
            sectionResult.RefinedProfileProbability = entity.RefinedProfileProbability.ToNullAsNaN();
            sectionResult.SetCommonFailureMechanismSectionResultProperties(entity);
        }
Beispiel #8
0
        public void Read_ValidEntityWithSections_ReturnSpecificFailureMechanism()
        {
            // Setup
            const string filePath = "sections/File/Path";
            FailureMechanismSectionEntity failureMechanismSectionEntity = CreateSimpleFailureMechanismSectionEntity();

            var sectionResultEntity = new NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity
            {
                FailureMechanismSectionEntity = failureMechanismSectionEntity
            };

            SectionResultTestHelper.SetSectionResult(sectionResultEntity);

            failureMechanismSectionEntity.NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntities = new List <NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity>
            {
                sectionResultEntity
            };

            var entity = new SpecificFailureMechanismEntity
            {
                N = 1.1,
                FailureMechanismSectionEntities = new List <FailureMechanismSectionEntity>
                {
                    failureMechanismSectionEntity
                },
                FailureMechanismSectionCollectionSourcePath = filePath
            };

            var collector = new ReadConversionCollector();

            // Call
            SpecificFailureMechanism specificFailureMechanism = entity.Read(collector);

            // Assert
            Assert.AreEqual(filePath, specificFailureMechanism.FailureMechanismSectionSourcePath);
            Assert.AreEqual(entity.FailureMechanismSectionEntities.Count, specificFailureMechanism.Sections.Count());

            SectionResultTestHelper.AssertSectionResult(entity.FailureMechanismSectionEntities
                                                        .SelectMany(fms => fms.NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntities)
                                                        .Single(),
                                                        specificFailureMechanism.SectionResults.Single());
        }
        public void CreateNonAdoptableWithProfileProbabilityFailureMechanismSectionResult_SectionResultWithNaNValues_ReturnsEntityWithExpectedResults()
        {
            // Setup
            var sectionResult = new NonAdoptableWithProfileProbabilityFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
            {
                ManualInitialFailureMechanismResultProfileProbability = double.NaN,
                ManualInitialFailureMechanismResultSectionProbability = double.NaN,
                RefinedProfileProbability = double.NaN,
                RefinedSectionProbability = double.NaN
            };

            // Call
            NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity entity = sectionResult.Create();

            // Assert
            Assert.IsNull(entity.ManualInitialFailureMechanismResultProfileProbability);
            Assert.IsNull(entity.ManualInitialFailureMechanismResultSectionProbability);
            Assert.IsNull(entity.RefinedProfileProbability);
            Assert.IsNull(entity.RefinedSectionProbability);
        }
Beispiel #10
0
        public void ReadNonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity_ParameterValues_SectionResultWithParameterValues()
        {
            // Setup
            var    random     = new Random(21);
            bool   isRelevant = random.NextBoolean();
            var    initialFailureMechanismResultType = random.NextEnumValue <NonAdoptableInitialFailureMechanismResultType>();
            double manualProfileProbability          = random.NextDouble();
            double manualSectionProbability          = random.NextDouble();
            var    furtherAnalysisType       = random.NextEnumValue <FailureMechanismSectionResultFurtherAnalysisType>();
            double refinedProfileProbability = random.NextDouble();
            double refinedSectionProbability = random.NextDouble();

            var entity = new NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity
            {
                IsRelevant = Convert.ToByte(isRelevant),
                InitialFailureMechanismResultType = Convert.ToByte(initialFailureMechanismResultType),
                ManualInitialFailureMechanismResultProfileProbability = manualProfileProbability,
                ManualInitialFailureMechanismResultSectionProbability = manualSectionProbability,
                FurtherAnalysisType       = Convert.ToByte(furtherAnalysisType),
                RefinedProfileProbability = refinedProfileProbability,
                RefinedSectionProbability = refinedSectionProbability
            };

            var sectionResult = new NonAdoptableWithProfileProbabilityFailureMechanismSectionResult(
                FailureMechanismSectionTestFactory.CreateFailureMechanismSection());

            // Call
            entity.Read(sectionResult);

            // Assert
            Assert.AreEqual(isRelevant, sectionResult.IsRelevant);
            Assert.AreEqual(initialFailureMechanismResultType, sectionResult.InitialFailureMechanismResultType);
            Assert.AreEqual(manualProfileProbability, sectionResult.ManualInitialFailureMechanismResultProfileProbability);
            Assert.AreEqual(manualSectionProbability, sectionResult.ManualInitialFailureMechanismResultSectionProbability);
            Assert.AreEqual(furtherAnalysisType, sectionResult.FurtherAnalysisType);
            Assert.AreEqual(refinedProfileProbability, sectionResult.RefinedProfileProbability);
            Assert.AreEqual(refinedSectionProbability, sectionResult.RefinedSectionProbability);
        }
Beispiel #11
0
 private static void AddEntitiesForSectionResults(
     IEnumerable <NonAdoptableWithProfileProbabilityFailureMechanismSectionResult> sectionResults,
     PersistenceRegistry registry)
 {
     foreach (NonAdoptableWithProfileProbabilityFailureMechanismSectionResult failureMechanismSectionResult in sectionResults)
     {
         NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity sectionResultEntity = failureMechanismSectionResult.Create();
         FailureMechanismSectionEntity section = registry.Get(failureMechanismSectionResult.Section);
         section.NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntities.Add(sectionResultEntity);
     }
 }