Exemplo n.º 1
0
        public void Create_IllustrationPointNodeWithValidChildren_ReturnFaultTreeIllustrationPointEntity(
            IEnumerable <IllustrationPointNode> children)
        {
            // Setup
            var random = new Random(21);

            var illustrationPoint = new FaultTreeIllustrationPoint("Illustration point name A",
                                                                   random.NextDouble(),
                                                                   Enumerable.Empty <Stochast>(),
                                                                   random.NextEnumValue <CombinationType>());
            int order = random.Next();

            var node = new IllustrationPointNode(illustrationPoint);

            node.SetChildren(children.ToArray());

            // Call
            FaultTreeIllustrationPointEntity entity = node.Create(order);

            // Assert
            AssertFaultTreeIllustrationPointEntity(illustrationPoint, entity);
            AssertIllustrationPointEntities(node.Children.ToArray(),
                                            entity.SubMechanismIllustrationPointEntities.ToArray(),
                                            entity.FaultTreeIllustrationPointEntity1.ToArray());

            Assert.AreEqual(order, entity.Order);
        }
Exemplo n.º 2
0
        public void Create_IllustrationPointNodeWithFaultTreeIllustrationPoint_ReturnFaultTreeIllustrationPointEntity()
        {
            // Setup
            var random = new Random(21);

            var illustrationPoint = new FaultTreeIllustrationPoint("Illustration point name",
                                                                   random.NextDouble(),
                                                                   Enumerable.Empty <Stochast>(),
                                                                   random.NextEnumValue <CombinationType>());
            int order = random.Next();

            var node = new IllustrationPointNode(illustrationPoint);

            // Call
            FaultTreeIllustrationPointEntity entity = node.Create(order);

            // Assert
            Assert.IsNull(entity.FaultTreeIllustrationPointEntity2);
            TestHelper.AssertAreEqualButNotSame(illustrationPoint.Name, entity.Name);
            Assert.AreEqual(illustrationPoint.Beta, entity.Beta, illustrationPoint.Beta.GetAccuracy());
            byte expectedCombinationType = Convert.ToByte(illustrationPoint.CombinationType);

            Assert.AreEqual(expectedCombinationType, entity.CombinationType);
            CollectionAssert.IsEmpty(entity.FaultTreeIllustrationPointEntity1);
            CollectionAssert.IsEmpty(entity.StochastEntities);
            CollectionAssert.IsEmpty(entity.SubMechanismIllustrationPointEntities);
            CollectionAssert.IsEmpty(entity.TopLevelFaultTreeIllustrationPointEntities);
            Assert.AreEqual(order, entity.Order);
        }
Exemplo n.º 3
0
        public void Create_IllustrationPointNodeWithSubMechanismIllustrationPoint_ThrowsNotSupportedException()
        {
            // Setup
            var node = new IllustrationPointNode(new TestSubMechanismIllustrationPoint());

            // Call
            TestDelegate call = () => node.Create(0);

            // Assert
            string message = Assert.Throws <NotSupportedException>(call).Message;

            Assert.AreEqual($"Illustration point type '{typeof(TestSubMechanismIllustrationPoint)}' is not supported.", message);
        }