private static void AssertSerializableTotalAssemblyResult(string expectedId,
                                                           ExportableAssessmentSectionAssemblyResult expectedAssessmentSectionAssemblyResult,
                                                           SerializableAssessmentProcess expectedAssessmentProcess,
                                                           SerializableTotalAssemblyResult serializableTotalAssembly)
 {
     Assert.AreEqual(expectedId, serializableTotalAssembly.Id);
     Assert.AreEqual(expectedAssessmentProcess.Id, serializableTotalAssembly.AssessmentProcessId);
     Assert.AreEqual(SerializableAssemblyMethodCreator.Create(expectedAssessmentSectionAssemblyResult.ProbabilityAssemblyMethod),
                     serializableTotalAssembly.ProbabilityAssemblyMethod);
     Assert.AreEqual(SerializableAssemblyMethodCreator.Create(expectedAssessmentSectionAssemblyResult.AssemblyGroupAssemblyMethod),
                     serializableTotalAssembly.AssemblyGroupAssemblyMethod);
     Assert.AreEqual(SerializableAssessmentSectionAssemblyGroupCreator.Create(expectedAssessmentSectionAssemblyResult.AssemblyGroup),
                     serializableTotalAssembly.AssemblyGroup);
     Assert.AreEqual(expectedAssessmentSectionAssemblyResult.Probability, serializableTotalAssembly.Probability);
 }
Пример #2
0
        public void Constructor_WithArguments_ExpectedValues()
        {
            // Setup
            var    random        = new Random(21);
            var    assemblyGroup = random.NextEnumValue <AssessmentSectionAssemblyGroup>();
            double probability   = random.NextDouble();
            var    assemblyGroupAssemblyMethod = random.NextEnumValue <ExportableAssemblyMethod>();
            var    probabilityAssemblyMethod   = random.NextEnumValue <ExportableAssemblyMethod>();

            // Call
            var assembly = new ExportableAssessmentSectionAssemblyResult(
                assemblyGroup, probability, assemblyGroupAssemblyMethod, probabilityAssemblyMethod);

            // Assert
            Assert.AreEqual(assemblyGroup, assembly.AssemblyGroup);
            Assert.AreEqual(probability, assembly.Probability);
            Assert.AreEqual(assemblyGroupAssemblyMethod, assembly.AssemblyGroupAssemblyMethod);
            Assert.AreEqual(probabilityAssemblyMethod, assembly.ProbabilityAssemblyMethod);
        }
Пример #3
0
        public void Constructor_WithValidArguments_ExpectedValues(string name, string id)
        {
            // Setup
            IEnumerable <Point2D> geometry = Enumerable.Empty <Point2D>();
            ExportableAssessmentSectionAssemblyResult       assessmentSectionAssembly      = ExportableAssessmentSectionAssemblyResultTestFactory.CreateResult();
            IEnumerable <ExportableFailureMechanism>        failureMechanisms              = Enumerable.Empty <ExportableFailureMechanism>();
            IEnumerable <ExportableCombinedSectionAssembly> combinedSectionAssemblyResults = Enumerable.Empty <ExportableCombinedSectionAssembly>();

            // Call
            var assessmentSection = new ExportableAssessmentSection(
                name, id, geometry, assessmentSectionAssembly, failureMechanisms, combinedSectionAssemblyResults);

            // Assert
            Assert.AreEqual(name, assessmentSection.Name);
            Assert.AreEqual(id, assessmentSection.Id);
            Assert.AreSame(geometry, assessmentSection.Geometry);
            Assert.AreSame(assessmentSectionAssembly, assessmentSection.AssessmentSectionAssembly);
            Assert.AreSame(failureMechanisms, assessmentSection.FailureMechanisms);
            Assert.AreSame(combinedSectionAssemblyResults, assessmentSection.CombinedSectionAssemblies);
        }
        public void CreateSerializableAssembly_WithValidArguments_ReturnsSerializableAssembly()
        {
            // Setup
            const string assessmentSectionName = "assessmentSectionName";
            const string assessmentSectionId   = "assessmentSectionId";

            IEnumerable <Point2D> geometry = CreateGeometry();
            ExportableAssessmentSectionAssemblyResult assessmentSectionAssembly =
                ExportableAssessmentSectionAssemblyResultTestFactory.CreateResult();
            IEnumerable <ExportableFailureMechanism> failureMechanisms =
                new[]
            {
                CreateFailureMechanism(),
                CreateFailureMechanism(),
                CreateFailureMechanism(),
                CreateFailureMechanism()
            };

            var exportableAssessmentSection = new ExportableAssessmentSection(assessmentSectionName,
                                                                              assessmentSectionId,
                                                                              geometry,
                                                                              assessmentSectionAssembly,
                                                                              failureMechanisms,
                                                                              new[]
            {
                CreateCombinedSectionAssembly(CreateCombinedFailureMechanismSection()),
                CreateCombinedSectionAssembly(CreateCombinedFailureMechanismSection())
            });

            // Call
            SerializableAssembly serializableAssembly = SerializableAssemblyCreator.Create(exportableAssessmentSection);

            // Assert
            Assert.AreEqual("Assemblage.0", serializableAssembly.Id);
            AssertSerializableBoundary(exportableAssessmentSection.Geometry, serializableAssembly.Boundary);

            SerializableFeatureMember[] serializableAssemblyFeatureMembers = serializableAssembly.FeatureMembers;
            Assert.AreEqual(24, serializableAssemblyFeatureMembers.Length);

            var serializableAssessmentSection = (SerializableAssessmentSection)serializableAssemblyFeatureMembers[0];

            AssertSerializableAssessmentSection($"Wks.{assessmentSectionId}", assessmentSectionName, geometry, serializableAssessmentSection);
            var serializableAssessmentProcess = (SerializableAssessmentProcess)serializableAssemblyFeatureMembers[1];

            AssertSerializableAssessmentProcess("Bp.0", serializableAssessmentSection, serializableAssessmentProcess);
            var serializableTotalAssemblyResult = (SerializableTotalAssemblyResult)serializableAssemblyFeatureMembers[2];

            AssertSerializableTotalAssemblyResult("Vo.0",
                                                  assessmentSectionAssembly,
                                                  serializableAssessmentProcess,
                                                  serializableTotalAssemblyResult);

            AssertFailureMechanismConnections(3, 0, serializableTotalAssemblyResult, serializableAssemblyFeatureMembers);
            AssertFailureMechanismConnections(4, 1, serializableTotalAssemblyResult, serializableAssemblyFeatureMembers);
            AssertFailureMechanismConnections(5, 2, serializableTotalAssemblyResult, serializableAssemblyFeatureMembers);
            AssertFailureMechanismConnections(6, 3, serializableTotalAssemblyResult, serializableAssemblyFeatureMembers);

            var combinedFailureMechanismSectionCollection = (SerializableFailureMechanismSectionCollection)serializableAssemblyFeatureMembers[17];

            AssertSerializableFailureMechanismSectionCollection("Vi.4", combinedFailureMechanismSectionCollection);
            AssertCombinedFailureMechanismSectionAssemblyConnections(11, 4, 0, combinedFailureMechanismSectionCollection, serializableTotalAssemblyResult, serializableAssemblyFeatureMembers);
            AssertCombinedFailureMechanismSectionAssemblyConnections(12, 5, 1, combinedFailureMechanismSectionCollection, serializableTotalAssemblyResult, serializableAssemblyFeatureMembers);
        }
Пример #5
0
        public void CreateExportableAssessmentSection_WithAssessmentSectionWithReferenceLine_ReturnsExpectedValues()
        {
            // Setup
            const string name = "assessmentSectionName";
            const string id   = "assessmentSectionId";

            var random            = new Random(21);
            var assessmentSection = new AssessmentSection(random.NextEnumValue <AssessmentSectionComposition>())
            {
                Name = name,
                Id   = id
            };

            ReferenceLineTestFactory.SetReferenceLineGeometry(assessmentSection.ReferenceLine);

            assessmentSection.SpecificFailureMechanisms.Add(new SpecificFailureMechanism());
            assessmentSection.SpecificFailureMechanisms.Add(new SpecificFailureMechanism());

            FailureMechanismTestHelper.AddSections(assessmentSection.Piping, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.MacroStabilityInwards, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.GrassCoverErosionInwards, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.HeightStructures, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.ClosingStructures, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.StabilityPointStructures, random.Next(1, 10));

            FailureMechanismTestHelper.AddSections(assessmentSection.StabilityStoneCover, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.WaveImpactAsphaltCover, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.GrassCoverErosionOutwards, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.DuneErosion, random.Next(1, 10));

            FailureMechanismTestHelper.AddSections(assessmentSection.Microstability, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.GrassCoverSlipOffOutwards, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.GrassCoverSlipOffInwards, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.PipingStructure, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.WaterPressureAsphaltCover, random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.SpecificFailureMechanisms.First(), random.Next(1, 10));
            FailureMechanismTestHelper.AddSections(assessmentSection.SpecificFailureMechanisms.Last(), random.Next(1, 10));

            using (new AssemblyToolCalculatorFactoryConfig())
            {
                // Call
                ExportableAssessmentSection exportableAssessmentSection = ExportableAssessmentSectionFactory.CreateExportableAssessmentSection(assessmentSection);

                // Assert
                Assert.AreEqual(name, exportableAssessmentSection.Name);
                Assert.AreEqual(id, exportableAssessmentSection.Id);
                CollectionAssert.AreEqual(assessmentSection.ReferenceLine.Points, exportableAssessmentSection.Geometry);

                ExportableAssessmentSectionAssemblyResult exportableAssessmentSectionAssemblyResult = exportableAssessmentSection.AssessmentSectionAssembly;
                Assert.AreEqual(ExportableAssemblyMethod.BOI2A1, exportableAssessmentSectionAssemblyResult.ProbabilityAssemblyMethod);
                Assert.AreEqual(ExportableAssemblyMethod.BOI2B1, exportableAssessmentSectionAssemblyResult.AssemblyGroupAssemblyMethod);
                Assert.AreEqual(AssessmentSectionAssemblyGroup.APlus, exportableAssessmentSectionAssemblyResult.AssemblyGroup);
                Assert.AreEqual(0.14, exportableAssessmentSectionAssemblyResult.Probability);

                AssertExportableFailureMechanisms(exportableAssessmentSection.FailureMechanisms, assessmentSection);

                Assert.AreEqual(1, exportableAssessmentSection.CombinedSectionAssemblies.Count());
                ExportableCombinedSectionAssembly exportableCombinedSectionAssembly = exportableAssessmentSection.CombinedSectionAssemblies.ElementAt(0);
                Assert.AreEqual(FailureMechanismSectionAssemblyGroup.Zero, exportableCombinedSectionAssembly.CombinedSectionAssemblyResult.AssemblyGroup);
                Assert.AreEqual(ExportableAssemblyMethod.BOI3C1, exportableCombinedSectionAssembly.CombinedSectionAssemblyResult.AssemblyGroupAssemblyMethod);
                Assert.AreEqual(0.0, exportableCombinedSectionAssembly.CombinedSectionAssemblyResult.FailureMechanismSection.StartDistance);
                Assert.AreEqual(1.0, exportableCombinedSectionAssembly.CombinedSectionAssemblyResult.FailureMechanismSection.EndDistance);
                AssertExportableFailureMechanismCombinedSectionAssemblyResults(exportableCombinedSectionAssembly.FailureMechanismResults, assessmentSection);
                Assert.AreEqual(ExportableAssemblyMethod.BOI3A1, exportableCombinedSectionAssembly.Section.AssemblyMethod);
                Assert.AreEqual(0.0, exportableCombinedSectionAssembly.Section.StartDistance);
                Assert.AreEqual(1.0, exportableCombinedSectionAssembly.Section.EndDistance);
            }
        }