コード例 #1
0
        public void Create_WithAssemblyMethod_ReturnsExpectedValues(ExportableAssemblyMethod assemblyMethod,
                                                                    SerializableAssemblyMethod expectedAssemblyMethod)
        {
            // Call
            SerializableAssemblyMethod serializableAssemblyMethod = SerializableAssemblyMethodCreator.Create(assemblyMethod);

            // Assert
            Assert.AreEqual(expectedAssemblyMethod, serializableAssemblyMethod);
        }
コード例 #2
0
        private static void AssertCombinedFailureMechanismSectionAssemblyResult(ExportableFailureMechanismCombinedSectionAssemblyResult expectedSectionResult,
                                                                                SerializableCombinedFailureMechanismSectionAssemblyResult actualSectionResult)
        {
            Assert.AreEqual(expectedSectionResult.Code, actualSectionResult.GenericFailureMechanismCode);

            ExportableFailureMechanismSubSectionAssemblyResult expectedSectionAssemblyResult = expectedSectionResult.SectionAssemblyResult;

            Assert.AreEqual(SerializableFailureMechanismSectionAssemblyGroupCreator.Create(expectedSectionAssemblyResult.AssemblyGroup),
                            actualSectionResult.AssemblyGroup);
            Assert.AreEqual(SerializableAssemblyMethodCreator.Create(expectedSectionAssemblyResult.AssemblyMethod),
                            actualSectionResult.AssemblyMethod);
        }
コード例 #3
0
        public void Create_InvalidAssemblyMethod_ThrowInvalidEnumArgumentException()
        {
            // Setup
            const ExportableAssemblyMethod assemblyMethod = (ExportableAssemblyMethod)999;

            // Call
            void Call() => SerializableAssemblyMethodCreator.Create(assemblyMethod);

            // Assert
            var message = $"The value of argument 'assemblyMethod' ({assemblyMethod}) is invalid for Enum type '{nameof(ExportableAssemblyMethod)}'.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(Call, message);
        }
コード例 #4
0
 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);
 }
        /// <summary>
        /// Asserts a <see cref="SerializableFailureMechanismSection"/> against
        /// an <see cref="ExportableCombinedFailureMechanismSection"/>.
        /// </summary>
        /// <param name="expectedSection">The <see cref="ExportableCombinedFailureMechanismSection"/> to assert against.</param>
        /// <param name="expectedCollection">The <see cref="SerializableFailureMechanismSectionCollection"/> the section belongs to.</param>
        /// <param name="actualSerializableSection">The <see cref="SerializableFailureMechanismSection"/> to assert.</param>
        /// <param name="expectedId">The expected id for the <see cref="SerializableFailureMechanismSection"/>.</param>
        /// <exception cref="AssertionException">Thrown when:
        /// <list type="bullet">
        /// <item>The id does not match with the expected id.</item>
        /// <item>The id of the failure mechanism section collection does not match.</item>
        /// <item>The geometry, start distance or the end distance of the failure mechanism section does not match.</item>
        /// <item>The failure mechanism section type does not match.</item>
        /// <item>The used assembly method to obtain the section does not match.</item>
        /// </list>
        /// </exception>
        public static void AssertFailureMechanismSection(ExportableCombinedFailureMechanismSection expectedSection,
                                                         SerializableFailureMechanismSectionCollection expectedCollection,
                                                         SerializableFailureMechanismSection actualSerializableSection,
                                                         int expectedId = 0)
        {
            Assert.AreEqual($"Bv.{expectedId}", actualSerializableSection.Id);
            Assert.AreEqual(expectedCollection.Id, actualSerializableSection.FailureMechanismSectionCollectionId);

            Assert.AreEqual(GeometrySerializationFormatter.Format(expectedSection.Geometry),
                            actualSerializableSection.Geometry.LineString.Geometry);
            Assert.AreEqual(expectedSection.StartDistance, actualSerializableSection.StartDistance.Value);
            Assert.AreEqual(expectedSection.EndDistance, actualSerializableSection.EndDistance.Value);
            Assert.AreEqual(SerializableFailureMechanismSectionType.Combined,
                            actualSerializableSection.FailureMechanismSectionType);
            Assert.AreEqual(SerializableAssemblyMethodCreator.Create(expectedSection.AssemblyMethod),
                            actualSerializableSection.AssemblyMethod);
        }
コード例 #6
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);
        }
        public void Create_WithExportableFailureMechanismCombinedSectionAssemblyResult_ReturnsSerializableCombinedFailureMechanismSectionAssemblyResult()
        {
            // Setup
            var random        = new Random(21);
            var sectionResult = new ExportableFailureMechanismCombinedSectionAssemblyResult(
                CreateSectionAssemblyResult(), random.NextEnumValue <ExportableFailureMechanismType>(), "code", "name");

            // Call
            SerializableCombinedFailureMechanismSectionAssemblyResult serializableResult =
                SerializableCombinedFailureMechanismSectionAssemblyResultCreator.Create(sectionResult);

            // Assert
            Assert.AreEqual(SerializableFailureMechanismTypeCreator.Create(sectionResult.FailureMechanismType),
                            serializableResult.FailureMechanismType);
            Assert.AreEqual(sectionResult.Code, serializableResult.GenericFailureMechanismCode);
            ExportableFailureMechanismSubSectionAssemblyResult expectedSectionAssemblyResult = sectionResult.SectionAssemblyResult;

            Assert.AreEqual(SerializableFailureMechanismSectionAssemblyGroupCreator.Create(expectedSectionAssemblyResult.AssemblyGroup),
                            serializableResult.AssemblyGroup);
            Assert.AreEqual(SerializableAssemblyMethodCreator.Create(expectedSectionAssemblyResult.AssemblyMethod),
                            serializableResult.AssemblyMethod);
        }
 /// <summary>
 /// Asserts a <see cref="SerializableFailureMechanismAssemblyResult"/> against an
 /// <see cref="ExportableFailureMechanismAssemblyResult"/>.
 /// </summary>
 /// <param name="expectedResult">The <see cref="ExportableFailureMechanismAssemblyResult"/> to assert against.</param>
 /// <param name="actualResult">The <see cref="SerializableFailureMechanismAssemblyResult"/> to assert.</param>
 /// <exception cref="AssertionException">Thrown when:
 /// <list type="bullet">
 /// <item>The assembly methods do not match, </item>
 /// <item>The probabilities do not match.</item>
 /// </list></exception>
 public static void AssertSerializableFailureMechanismAssemblyResult(ExportableFailureMechanismAssemblyResult expectedResult,
                                                                     SerializableFailureMechanismAssemblyResult actualResult)
 {
     Assert.AreEqual(expectedResult.Probability, actualResult.Probability);
     Assert.AreEqual(SerializableAssemblyMethodCreator.Create(expectedResult.AssemblyMethod), actualResult.AssemblyMethod);
 }