public void Create_ValidTopLevelSubMechanismIllustrationPoint_ReturnsEntityWithSubMechanismIllustrationPointEntity()
        {
            // Setup
            var random            = new Random(21);
            var illustrationPoint = new SubMechanismIllustrationPoint("Illustration point name",
                                                                      random.NextDouble(),
                                                                      Enumerable.Empty <SubMechanismIllustrationPointStochast>(),
                                                                      Enumerable.Empty <IllustrationPointResult>());

            var windDirection = new WindDirection("WindDirection Name", random.NextDouble());
            var topLevelSubMechanismIllustrationPoint = new TopLevelSubMechanismIllustrationPoint(windDirection,
                                                                                                  "Just a situation",
                                                                                                  illustrationPoint);
            int order = random.Next();

            // Call
            TopLevelSubMechanismIllustrationPointEntity entity =
                topLevelSubMechanismIllustrationPoint.Create(order);

            // Assert
            TestHelper.AssertAreEqualButNotSame(topLevelSubMechanismIllustrationPoint.ClosingSituation, entity.ClosingSituation);
            Assert.AreEqual(order, entity.Order);

            TestHelper.AssertAreEqualButNotSame(windDirection.Name, entity.WindDirectionName);
            Assert.AreEqual(windDirection.Angle, entity.WindDirectionAngle, windDirection.Angle.GetAccuracy());

            SubMechanismIllustrationPointEntity subMechanismIllustrationPointEntity = entity.SubMechanismIllustrationPointEntity;

            TestHelper.AssertAreEqualButNotSame(illustrationPoint.Name, subMechanismIllustrationPointEntity.Name);
            Assert.AreEqual(illustrationPoint.Beta, subMechanismIllustrationPointEntity.Beta, illustrationPoint.Beta.GetAccuracy());
            CollectionAssert.IsEmpty(subMechanismIllustrationPointEntity.IllustrationPointResultEntities);
            CollectionAssert.IsEmpty(subMechanismIllustrationPointEntity.SubMechanismIllustrationPointStochastEntities);
        }
Ejemplo n.º 2
0
        private static void AssertTopLevelSubMechanismIllustrationPoint(
            TopLevelSubMechanismIllustrationPointEntity illustrationPointEntity,
            TopLevelSubMechanismIllustrationPoint readTopLevelSubMechanismIllustrationPoint)
        {
            Assert.AreEqual(illustrationPointEntity.ClosingSituation, readTopLevelSubMechanismIllustrationPoint.ClosingSituation);

            WindDirection actualWindDirection = readTopLevelSubMechanismIllustrationPoint.WindDirection;

            Assert.AreEqual(illustrationPointEntity.WindDirectionName, actualWindDirection.Name);
            Assert.AreEqual(illustrationPointEntity.WindDirectionAngle, actualWindDirection.Angle, actualWindDirection.Angle);

            Assert.IsNotNull(readTopLevelSubMechanismIllustrationPoint.SubMechanismIllustrationPoint);
        }
        /// <summary>
        /// Reads the <see cref="TopLevelSubMechanismIllustrationPointEntity"/> and
        /// uses the information to construct a <see cref="TopLevelSubMechanismIllustrationPoint"/>.
        /// </summary>
        /// <param name="entity">The <see cref="TopLevelSubMechanismIllustrationPointEntity"/>
        /// to create a <see cref="TopLevelSubMechanismIllustrationPoint"/> for.</param>
        /// <returns>A new <see cref="TopLevelSubMechanismIllustrationPoint"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="entity"/>
        /// is <c>null</c>.</exception>
        internal static TopLevelSubMechanismIllustrationPoint Read(this TopLevelSubMechanismIllustrationPointEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            WindDirection windDirection = GetWindDirection(entity);

            SubMechanismIllustrationPoint subMechanismIllustrationPoint =
                entity.SubMechanismIllustrationPointEntity.Read();

            return(new TopLevelSubMechanismIllustrationPoint(windDirection,
                                                             entity.ClosingSituation,
                                                             subMechanismIllustrationPoint));
        }
        private static void AssertTopLevelIllustrationPointEntity <TTopLevelIllustrationPoint>(
            TTopLevelIllustrationPoint illustrationPoint,
            TopLevelSubMechanismIllustrationPointEntity illustrationPointEntity,
            int expectedOrder)
            where TTopLevelIllustrationPoint : TopLevelIllustrationPointBase
        {
            TestHelper.AssertAreEqualButNotSame(illustrationPoint.ClosingSituation,
                                                illustrationPointEntity.ClosingSituation);

            WindDirection expectedWindDirection = illustrationPoint.WindDirection;

            TestHelper.AssertAreEqualButNotSame(expectedWindDirection.Name, illustrationPointEntity.WindDirectionName);
            Assert.AreEqual(expectedWindDirection.Angle, illustrationPointEntity.WindDirectionAngle,
                            expectedWindDirection.Angle.GetAccuracy());
            TestHelper.AssertAreEqualButNotSame(illustrationPoint.ClosingSituation, illustrationPointEntity.ClosingSituation);

            Assert.AreEqual(expectedOrder, illustrationPointEntity.Order);
        }
        public void Read_ValidEntity_ReturnsTopLevelSubMechanismIllustrationPoint()
        {
            // Setup
            var random = new Random(21);

            var subMechanismIllustrationPointEntity = new SubMechanismIllustrationPointEntity
            {
                Name = "Illustration point name",
                Beta = random.NextDouble()
            };

            var entity = new TopLevelSubMechanismIllustrationPointEntity
            {
                ClosingSituation   = "closingSituation",
                WindDirectionName  = "WindDirectionName",
                WindDirectionAngle = random.NextDouble(),
                SubMechanismIllustrationPointEntity = subMechanismIllustrationPointEntity
            };

            // Call
            TopLevelSubMechanismIllustrationPoint topLevelSubMechanismIllustrationPoint = entity.Read();

            // Assert
            Assert.AreEqual(entity.ClosingSituation, topLevelSubMechanismIllustrationPoint.ClosingSituation);

            WindDirection actualWindDirection = topLevelSubMechanismIllustrationPoint.WindDirection;

            Assert.AreEqual(entity.WindDirectionName, actualWindDirection.Name);
            Assert.AreEqual(entity.WindDirectionAngle, actualWindDirection.Angle,
                            actualWindDirection.Angle.GetAccuracy());

            SubMechanismIllustrationPoint actualIllustrationPoint = topLevelSubMechanismIllustrationPoint.SubMechanismIllustrationPoint;

            Assert.AreEqual(subMechanismIllustrationPointEntity.Name, actualIllustrationPoint.Name);
            Assert.AreEqual(subMechanismIllustrationPointEntity.Beta, actualIllustrationPoint.Beta,
                            actualIllustrationPoint.Beta.GetAccuracy());
            CollectionAssert.IsEmpty(actualIllustrationPoint.Stochasts);
            CollectionAssert.IsEmpty(actualIllustrationPoint.IllustrationPointResults);
        }
 private static WindDirection GetWindDirection(TopLevelSubMechanismIllustrationPointEntity entity)
 {
     return(new WindDirection(entity.WindDirectionName,
                              entity.WindDirectionAngle));
 }