public void Create_WithValidArguments_ReturnsAggregatedSerializableFailureMechanism()
        {
            // Setup
            var random           = new Random(21);
            var failureMechanism = new ExportableFailureMechanism(
                ExportableFailureMechanismAssemblyResultTestFactory.CreateResult(),
                new[]
            {
                ExportableFailureMechanismSectionAssemblyResultTestFactory.CreateWithProbability(
                    ExportableFailureMechanismSectionTestFactory.CreateExportableFailureMechanismSection(random.Next()), random.Next()),
                ExportableFailureMechanismSectionAssemblyResultTestFactory.CreateWithProbability(
                    ExportableFailureMechanismSectionTestFactory.CreateExportableFailureMechanismSection(random.Next()), random.Next())
            },
                random.NextEnumValue <ExportableFailureMechanismType>(),
                "code",
                "name");

            var idGenerator = new IdentifierGenerator();

            const string totalAssemblyId           = "totalAssemblyId";
            var          serializableTotalAssembly = new SerializableTotalAssemblyResult(totalAssemblyId,
                                                                                         new SerializableAssessmentProcess(),
                                                                                         random.NextEnumValue <SerializableAssemblyMethod>(),
                                                                                         random.NextEnumValue <SerializableAssemblyMethod>(),
                                                                                         random.NextEnumValue <SerializableAssessmentSectionAssemblyGroup>(),
                                                                                         random.NextDouble());

            // Call
            AggregatedSerializableFailureMechanism aggregatedFailureMechanism =
                AggregatedSerializableFailureMechanismCreator.Create(idGenerator, serializableTotalAssembly, failureMechanism);

            // Assert
            SerializableFailureMechanism serializableFailureMechanism = aggregatedFailureMechanism.FailureMechanism;

            Assert.AreEqual("Fm.0", serializableFailureMechanism.Id);
            Assert.AreEqual(serializableTotalAssembly.Id, serializableFailureMechanism.TotalAssemblyResultId);
            Assert.AreEqual(SerializableFailureMechanismTypeCreator.Create(failureMechanism.FailureMechanismType),
                            serializableFailureMechanism.FailureMechanismType);
            Assert.AreEqual(failureMechanism.Code, serializableFailureMechanism.GenericFailureMechanismCode);

            SerializableFailureMechanismAssemblyResultTestHelper.AssertSerializableFailureMechanismAssemblyResult(failureMechanism.FailureMechanismAssembly,
                                                                                                                  serializableFailureMechanism.FailureMechanismAssemblyResult);

            SerializableFailureMechanismSectionCollection serializableFailureMechanismSectionCollection = aggregatedFailureMechanism.FailureMechanismSectionCollection;

            Assert.AreEqual("Vi.0", serializableFailureMechanismSectionCollection.Id);

            AssertFailureMechanismSectionAssemblies(failureMechanism,
                                                    serializableFailureMechanismSectionCollection,
                                                    serializableFailureMechanism,
                                                    aggregatedFailureMechanism.FailureMechanismSections,
                                                    aggregatedFailureMechanism.FailureMechanismSectionAssemblyResults);
        }
        private static ExportableFailureMechanism CreateFailureMechanism()
        {
            var random = new Random(21);
            ExportableFailureMechanismSection failureMechanismSection = ExportableFailureMechanismSectionTestFactory.CreateExportableFailureMechanismSection();

            return(new ExportableFailureMechanism(
                       ExportableFailureMechanismAssemblyResultTestFactory.CreateResult(),
                       new[]
            {
                ExportableFailureMechanismSectionAssemblyResultTestFactory.CreateWithProbability(failureMechanismSection, random.Next())
            },
                       random.NextEnumValue <ExportableFailureMechanismType>(),
                       "code",
                       "name"));
        }
Exemple #3
0
        public void Create_ValidData_ReturnsSerializableFailureMechanismAssemblyResult()
        {
            // Setup
            ExportableFailureMechanismSectionAssemblyWithProbabilityResult sectionResult = ExportableFailureMechanismSectionAssemblyResultTestFactory.CreateWithProbability(
                ExportableFailureMechanismSectionTestFactory.CreateExportableFailureMechanismSection(), 21);

            // Call
            SerializableFailureMechanismSectionAssemblyResult serializableAssemblyResult = SerializableFailureMechanismSectionAssemblyResultCreator.Create(sectionResult);

            // Assert
            Assert.AreEqual(SerializableAssemblyMethodCreator.Create(sectionResult.ProbabilityAssemblyMethod),
                            serializableAssemblyResult.ProbabilityAssemblyMethod);
            Assert.AreEqual(SerializableAssemblyMethodCreator.Create(sectionResult.AssemblyGroupAssemblyMethod),
                            serializableAssemblyResult.AssemblyGroupAssemblyMethod);
            Assert.AreEqual(SerializableFailureMechanismSectionAssemblyGroupCreator.Create(
                                sectionResult.AssemblyGroup), serializableAssemblyResult.AssemblyGroup);
            Assert.AreEqual(sectionResult.Probability, serializableAssemblyResult.Probability);
        }