/// <summary> /// Creates a new instance of <see cref="SerializableFailureMechanismSection"/>. /// </summary> /// <param name="id">The unique assembly ID.</param> /// <param name="failureMechanismSectionCollection">The failure mechanism sections object the section belong to.</param> /// <param name="startDistance">The distance over the reference line where this section starts in meters.</param> /// <param name="endDistance">The distance over the reference line where this section ends in meters.</param> /// <param name="geometry">The geometry of the section.</param> /// <param name="sectionType">The type of the section.</param> /// <param name="assemblyMethod">The assembly method used to create this section.</param> /// <exception cref="ArgumentNullException">Thrown when <paramref name="failureMechanismSectionCollection"/>, /// or <paramref name="geometry"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException">Thrown when: /// <list type="bullet"> /// <item><paramref name="geometry"/> contains no elements.</item> /// <item><paramref name="id"/> is invalid.</item> /// </list> /// </exception> public SerializableFailureMechanismSection(string id, SerializableFailureMechanismSectionCollection failureMechanismSectionCollection, double startDistance, double endDistance, IEnumerable <Point2D> geometry, SerializableFailureMechanismSectionType sectionType, SerializableAssemblyMethod?assemblyMethod = null) { SerializableIdValidator.ThrowIfInvalid(id); if (failureMechanismSectionCollection == null) { throw new ArgumentNullException(nameof(failureMechanismSectionCollection)); } if (geometry == null) { throw new ArgumentNullException(nameof(geometry)); } Id = id; StartDistance = new SerializableMeasure(startDistance); EndDistance = new SerializableMeasure(endDistance); FailureMechanismSectionCollectionId = failureMechanismSectionCollection.Id; Geometry = new SerializableLine(geometry); Length = new SerializableMeasure(Math2D.Length(geometry)); AssemblyMethod = assemblyMethod; FailureMechanismSectionType = sectionType; }
public void Constructor_WithValidData_ReturnsExpectedValues() { // Setup double value = new Random(39).NextDouble(); // Call var measure = new SerializableMeasure(value); // Assert Assert.AreEqual("m", measure.UnitOfMeasure); Assert.AreEqual(value, measure.Value); }
public void DefaultConstructor_ReturnsDefaultValues() { // Call var measure = new SerializableMeasure(); // Assert Assert.AreEqual("m", measure.UnitOfMeasure); Assert.IsNaN(measure.Value); SerializableAttributeTestHelper.AssertXmlAttributeAttribute <SerializableMeasure>( nameof(SerializableMeasure.UnitOfMeasure), "uom"); IEnumerable <XmlTextAttribute> xmlTextAttributes = TypeUtils.GetPropertyAttributes <SerializableMeasure, XmlTextAttribute>( nameof(SerializableMeasure.Value)); Assert.AreEqual(1, xmlTextAttributes.Count()); }
/// <summary> /// Creates a new instance of <see cref="SerializableAssessmentSection"/>. /// </summary> /// <param name="id">The unique assembly ID.</param> /// <param name="name">The name of the assessment section.</param> /// <param name="geometry">The geometry of the reference line.</param> /// <exception cref="ArgumentNullException">Thrown when any parameter except <paramref name="id"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException">Thrown when: /// <list type="bullet"> /// <item><paramref name="geometry"/> contains no elements.</item> /// <item><paramref name="id"/> is invalid.</item> /// </list> /// </exception> public SerializableAssessmentSection(string id, string name, IEnumerable <Point2D> geometry) : this() { SerializableIdValidator.ThrowIfInvalid(id); if (name == null) { throw new ArgumentNullException(nameof(name)); } if (geometry == null) { throw new ArgumentNullException(nameof(geometry)); } Id = id; Name = name; ReferenceLineLength = new SerializableMeasure(Math2D.Length(geometry)); ReferenceLineGeometry = new SerializableLine(geometry); }