コード例 #1
0
        /// <summary>
        /// Creates a new instance of <see cref="SerializableFailureMechanismSectionAssembly"/>.
        /// </summary>
        /// <param name="id">The unique assembly ID.</param>
        /// <param name="failureMechanism">The failure mechanism this assembly belongs to.</param>
        /// <param name="section">The section this assembly belongs to.</param>
        /// <param name="sectionResult">The assembly result for this section assembly.</param>
        /// <exception cref="ArgumentNullException">Thrown when any parameter except <paramref name="id"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when <paramref name="id"/> is invalid.</exception>
        public SerializableFailureMechanismSectionAssembly(string id,
                                                           SerializableFailureMechanism failureMechanism,
                                                           SerializableFailureMechanismSection section,
                                                           SerializableFailureMechanismSectionAssemblyResult sectionResult)
            : this()
        {
            SerializableIdValidator.ThrowIfInvalid(id);

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

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

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

            Id = id;
            FailureMechanismId        = failureMechanism.Id;
            FailureMechanismSectionId = section.Id;
            SectionResult             = sectionResult;
        }
コード例 #2
0
        public void Constructor_WithValidData_ReturnsExpectedValues()
        {
            // Setup
            const string id = "id";

            var random           = new Random(39);
            var failureMechanism = new SerializableFailureMechanism(
                "failureMechanismID", random.NextEnumValue <SerializableFailureMechanismType>(),
                "code", "name", new SerializableTotalAssemblyResult(), new SerializableFailureMechanismAssemblyResult());
            var section = new SerializableFailureMechanismSection("sectionID",
                                                                  new SerializableFailureMechanismSectionCollection(),
                                                                  random.NextDouble(),
                                                                  random.NextDouble(),
                                                                  new[]
            {
                new Point2D(random.NextDouble(), random.NextDouble())
            },
                                                                  SerializableFailureMechanismSectionType.FailureMechanism);
            var sectionResult = new SerializableFailureMechanismSectionAssemblyResult();

            // Call
            var sectionAssembly = new SerializableFailureMechanismSectionAssembly(
                id, failureMechanism, section, sectionResult);

            // Assert
            Assert.AreEqual(id, sectionAssembly.Id);
            Assert.AreEqual(failureMechanism.Id, sectionAssembly.FailureMechanismId);
            Assert.AreEqual(section.Id, sectionAssembly.FailureMechanismSectionId);
            Assert.AreSame(sectionResult, sectionAssembly.SectionResult);
        }
        public void ShouldSerializeProbability_WithProbabilityAndAssemblyGroupNotDominant_ReturnsFalse()
        {
            // Setup
            var random         = new Random(39);
            var assemblyResult = new SerializableFailureMechanismSectionAssemblyResult(
                random.NextEnumValue <SerializableAssemblyMethod>(),
                random.NextEnumValue <SerializableAssemblyMethod>(),
                SerializableFailureMechanismSectionAssemblyGroup.NotDominant,
                random.NextDouble());

            // Call
            bool shouldSerialize = assemblyResult.ShouldSerializeProbability();

            // Assert
            Assert.IsFalse(shouldSerialize);
        }
コード例 #4
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 Constructor_ExpectedValues()
        {
            // Setup
            var    random = new Random(21);
            var    probabilityAssemblyMethod   = random.NextEnumValue <SerializableAssemblyMethod>();
            var    assemblyGroupAssemblyMethod = random.NextEnumValue <SerializableAssemblyMethod>();
            var    assemblyGroup = random.NextEnumValue <SerializableFailureMechanismSectionAssemblyGroup>();
            double probability   = random.NextDouble();

            // Call
            var assemblyResult = new SerializableFailureMechanismSectionAssemblyResult(
                probabilityAssemblyMethod, assemblyGroupAssemblyMethod, assemblyGroup, probability);

            // Assert
            Assert.AreEqual(assemblyGroup, assemblyResult.AssemblyGroup);
            Assert.AreEqual(probability, assemblyResult.Probability);
            Assert.AreEqual(probabilityAssemblyMethod, assemblyResult.ProbabilityAssemblyMethod);
            Assert.AreEqual(assemblyGroupAssemblyMethod, assemblyResult.AssemblyGroupAssemblyMethod);
            Assert.AreEqual("VOLLDG", assemblyResult.Status);
        }
        public void DefaultConstructor_ReturnsDefaultValues()
        {
            // Call
            var assemblyResult = new SerializableFailureMechanismSectionAssemblyResult();

            // Assert
            Assert.AreEqual((SerializableAssemblyMethod)0, assemblyResult.ProbabilityAssemblyMethod);
            Assert.AreEqual((SerializableAssemblyMethod)0, assemblyResult.AssemblyGroupAssemblyMethod);
            Assert.AreEqual((SerializableFailureMechanismSectionAssemblyGroup)0, assemblyResult.AssemblyGroup);
            Assert.AreEqual(0, assemblyResult.Probability);
            Assert.AreEqual("VOLLDG", assemblyResult.Status);

            SerializableAttributeTestHelper.AssertXmlElementAttribute <SerializableFailureMechanismSectionAssemblyResult>(
                nameof(SerializableFailureMechanismSectionAssemblyResult.ProbabilityAssemblyMethod), "assemblagemethodeFaalkans");
            SerializableAttributeTestHelper.AssertXmlElementAttribute <SerializableFailureMechanismSectionAssemblyResult>(
                nameof(SerializableFailureMechanismSectionAssemblyResult.AssemblyGroupAssemblyMethod), "assemblagemethodeDuidingsklasse");
            SerializableAttributeTestHelper.AssertXmlElementAttribute <SerializableFailureMechanismSectionAssemblyResult>(
                nameof(SerializableFailureMechanismSectionAssemblyResult.AssemblyGroup), "duidingsklasse");
            SerializableAttributeTestHelper.AssertXmlElementAttribute <SerializableFailureMechanismSectionAssemblyResult>(
                nameof(SerializableFailureMechanismSectionAssemblyResult.Probability), "faalkans");
            SerializableAttributeTestHelper.AssertXmlElementAttribute <SerializableFailureMechanismAssemblyResult>(
                nameof(SerializableFailureMechanismAssemblyResult.Status), "status");
        }