示例#1
0
        public void Read_ValidEntityWithIllustrationPoints_ReturnsIllustrationPointNode()
        {
            // Setup
            var random = new Random(21);
            var entity = new FaultTreeIllustrationPointEntity
            {
                Name            = "FaultTreeIllustrationPointEntity",
                Beta            = random.NextDouble(),
                CombinationType = Convert.ToByte(random.NextEnumValue <CombinationType>()),
                SubMechanismIllustrationPointEntities =
                {
                    new SubMechanismIllustrationPointEntity
                    {
                        Name  = "SubMechanismIllustrationPointEntity",
                        Beta  = random.NextDouble(),
                        Order = 10
                    }
                },
                FaultTreeIllustrationPointEntity1 =
                {
                    new FaultTreeIllustrationPointEntity
                    {
                        Name            = "FaultTreeIllustrationPointEntity",
                        Beta            = random.NextDouble(),
                        CombinationType = Convert.ToByte(random.NextEnumValue <CombinationType>()),
                        Order           = 5
                    }
                }
            };

            // Call
            IllustrationPointNode node = entity.Read();

            // Assert
            var illustrationPoint = node.Data as FaultTreeIllustrationPoint;

            Assert.IsNotNull(illustrationPoint);
            Assert.AreEqual(entity.Name, illustrationPoint.Name);
            Assert.AreEqual(entity.Beta, illustrationPoint.Beta, illustrationPoint.Beta.GetAccuracy());
            Assert.AreEqual((CombinationType)entity.CombinationType, illustrationPoint.CombinationType);

            IllustrationPointNode[] children = node.Children.ToArray();
            Assert.AreEqual(2, children.Length);

            AssertFaultTreeIllustrationPointNode(entity.FaultTreeIllustrationPointEntity1.First(), children[0]);
            AssertSubMechanismIllustrationPointNode(entity.SubMechanismIllustrationPointEntities.First(), children[1]);
        }
示例#2
0
        public void Read_ValidEntityWithStochasts_ReturnsIllustrationPointNode()
        {
            // Setup
            var random = new Random(21);

            var combinationType = random.NextEnumValue <CombinationType>();
            var entity          = new FaultTreeIllustrationPointEntity
            {
                Name             = "FaultTreeIllustrationPointEntity",
                Beta             = random.NextDouble(),
                CombinationType  = Convert.ToByte(combinationType),
                StochastEntities =
                {
                    new StochastEntity
                    {
                        Alpha    = random.NextDouble(),
                        Duration = random.NextDouble(),
                        Name     = "StochastEntity"
                    }
                }
            };

            // Call
            IllustrationPointNode node = entity.Read();

            // Assert
            var illustrationPoint = node.Data as FaultTreeIllustrationPoint;

            Assert.IsNotNull(illustrationPoint);
            Assert.AreEqual(entity.Name, illustrationPoint.Name);
            Assert.AreEqual(entity.Beta, illustrationPoint.Beta, illustrationPoint.Beta.GetAccuracy());
            Assert.AreEqual(combinationType, illustrationPoint.CombinationType);

            AssertStochasts(entity.StochastEntities.ToArray(), illustrationPoint.Stochasts.ToArray());

            CollectionAssert.IsEmpty(node.Children);
        }