Exemplo n.º 1
0
        private static void AssertCombinedFailureMechanismSectionAssemblies(IEnumerable <ExportableCombinedSectionAssembly> expectedCombinedSectionAssemblies,
                                                                            SerializableFailureMechanismSectionCollection expectedSerializableFailureMechanismSectionCollection,
                                                                            SerializableTotalAssemblyResult expectedSerializableTotalAssemblyResult,
                                                                            IEnumerable <SerializableFailureMechanismSection> serializableFailureMechanismSections,
                                                                            IEnumerable <SerializableCombinedFailureMechanismSectionAssembly> serializableFailureMechanismSectionAssemblies)
        {
            IEnumerable <ExportableCombinedFailureMechanismSection> expectedSections = expectedCombinedSectionAssemblies.Select(csar => csar.Section);
            int expectedNrOfSections = expectedSections.Count();

            Assert.AreEqual(expectedNrOfSections, serializableFailureMechanismSections.Count());

            Assert.AreEqual(expectedCombinedSectionAssemblies.Count(), serializableFailureMechanismSectionAssemblies.Count());

            var sectionId         = 0;
            var combinedSectionId = 0;

            for (var i = 0; i < expectedNrOfSections; i++)
            {
                ExportableCombinedFailureMechanismSection expectedSection = expectedSections.ElementAt(i);
                SerializableFailureMechanismSection       actualSection   = serializableFailureMechanismSections.ElementAt(i);

                SerializableFailureMechanismSectionTestHelper.AssertFailureMechanismSection(expectedSection,
                                                                                            expectedSerializableFailureMechanismSectionCollection,
                                                                                            actualSection,
                                                                                            sectionId++);

                SerializableCombinedFailureMechanismSectionAssembly actualSectionAssemblyResult = serializableFailureMechanismSectionAssemblies.ElementAt(i);
                Assert.AreEqual($"Gf.{combinedSectionId++}", actualSectionAssemblyResult.Id);
                Assert.AreEqual(actualSection.Id, actualSectionAssemblyResult.FailureMechanismSectionId);
                Assert.AreEqual(expectedSerializableTotalAssemblyResult.Id, actualSectionAssemblyResult.TotalAssemblyResultId);

                AssertCombinedFailureMechanismSectionResults(expectedCombinedSectionAssemblies.ElementAt(i).FailureMechanismResults,
                                                             actualSectionAssemblyResult.FailureMechanismResults);
            }
        }
Exemplo n.º 2
0
        public void Create_WithSection_ReturnsSerializableFailureMechanismSection()
        {
            // Setup
            const string collectionId = "collectionId";
            var          collection   = new SerializableFailureMechanismSectionCollection(collectionId);

            var idGenerator = new IdentifierGenerator();
            ExportableFailureMechanismSection section = ExportableFailureMechanismSectionTestFactory.CreateExportableFailureMechanismSection();

            // Call
            SerializableFailureMechanismSection serializableSection =
                SerializableFailureMechanismSectionCreator.Create(idGenerator, collection, section);

            // Assert
            SerializableFailureMechanismSectionTestHelper.AssertFailureMechanismSection(section, collection, serializableSection);
        }
        private static void AssertFailureMechanismSectionAssemblies(
            ExportableFailureMechanism expectedFailureMechanism,
            SerializableFailureMechanismSectionCollection expectedSerializableFailureMechanismSectionCollection,
            SerializableFailureMechanism expectedSerializableFailureMechanism,
            IEnumerable <SerializableFailureMechanismSection> serializableFailureMechanismSections,
            IEnumerable <SerializableFailureMechanismSectionAssembly> serializableFailureMechanismSectionAssemblies)
        {
            IEnumerable <ExportableFailureMechanismSection> expectedSections = expectedFailureMechanism.SectionAssemblyResults.Select(sar => sar.FailureMechanismSection);
            int expectedNrOfSections = expectedSections.Count();

            Assert.AreEqual(expectedNrOfSections, serializableFailureMechanismSections.Count());

            IEnumerable <ExportableFailureMechanismSectionAssemblyWithProbabilityResult> expectedSectionAssemblyResults = expectedFailureMechanism.SectionAssemblyResults;

            Assert.AreEqual(expectedSectionAssemblyResults.Count(), serializableFailureMechanismSectionAssemblies.Count());

            var sectionId         = 0;
            var sectionAssemblyId = 0;

            for (var i = 0; i < expectedNrOfSections; i++)
            {
                ExportableFailureMechanismSection   expectedSection = expectedSections.ElementAt(i);
                SerializableFailureMechanismSection actualSection   = serializableFailureMechanismSections.ElementAt(i);

                SerializableFailureMechanismSectionTestHelper.AssertFailureMechanismSection(expectedSection,
                                                                                            expectedSerializableFailureMechanismSectionCollection,
                                                                                            actualSection,
                                                                                            sectionId++);

                ExportableFailureMechanismSectionAssemblyWithProbabilityResult expectedSectionAssemblyResult = expectedSectionAssemblyResults.ElementAt(i);
                SerializableFailureMechanismSectionAssembly actualSectionAssemblyResult = serializableFailureMechanismSectionAssemblies.ElementAt(i);
                Assert.AreEqual($"Fa.{sectionAssemblyId++}", actualSectionAssemblyResult.Id);
                Assert.AreEqual(expectedSerializableFailureMechanism.Id, actualSectionAssemblyResult.FailureMechanismId);

                Assert.AreEqual(actualSection.Id, actualSectionAssemblyResult.FailureMechanismSectionId);
                Assert.AreEqual(SerializableFailureMechanismSectionAssemblyGroupCreator.Create(
                                    expectedSectionAssemblyResult.AssemblyGroup), actualSectionAssemblyResult.SectionResult.AssemblyGroup);
                Assert.AreEqual(expectedSectionAssemblyResult.Probability, actualSectionAssemblyResult.SectionResult.Probability);
            }
        }