Beispiel #1
0
        private static IEnumerable <TestCaseData> GetValidIllustrationPointNodes()
        {
            yield return(new TestCaseData(new List <IllustrationPointNode>
            {
                new IllustrationPointNode(new TestSubMechanismIllustrationPoint("A")),
                new IllustrationPointNode(new TestSubMechanismIllustrationPoint("B"))
            }).SetName("SubMechanismIllustrationPoints"));

            yield return(new TestCaseData(new List <IllustrationPointNode>
            {
                new IllustrationPointNode(new TestSubMechanismIllustrationPoint("A")),
                new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPointCombinationTypeAnd("B"))
            }).SetName("SubMechanismAndFaultTreeIllustrationPoints"));

            yield return(new TestCaseData(new List <IllustrationPointNode>
            {
                new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPointCombinationTypeAnd("A")),
                new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPointCombinationTypeAnd("B"))
            }).SetName("FaultTreeIllustrationPoints"));

            var node = new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPointCombinationTypeAnd("A"));

            node.SetChildren(new[]
            {
                new IllustrationPointNode(new TestSubMechanismIllustrationPoint("B")),
                new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPointCombinationTypeAnd("C"))
            });

            yield return(new TestCaseData(new List <IllustrationPointNode>
            {
                new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPointCombinationTypeAnd("AA")),
                node
            }).SetName("FaultTreeIllustrationPointsWithChildren"));
        }
        public void CreateGeneralResultFaultTreeIllustrationPointEntity_ValidGeneralResultsWithIllustrationPoints_ReturnsEntityWithTopLevelFaultTreeIllustrationPointEntities()
        {
            // Setup
            var random = new Random(22);

            var generalResult = new GeneralResult <TopLevelFaultTreeIllustrationPoint>(
                new WindDirection("SSE", random.NextDouble()),
                Enumerable.Empty <Stochast>(),
                new[]
            {
                new TopLevelFaultTreeIllustrationPoint(
                    WindDirectionTestFactory.CreateTestWindDirection(),
                    "IllustrationPointOne",
                    new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPoint())),
                new TopLevelFaultTreeIllustrationPoint(
                    WindDirectionTestFactory.CreateTestWindDirection(),
                    "IllustrationPointTwo",
                    new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPoint()))
            });

            // Call
            GeneralResultFaultTreeIllustrationPointEntity entity =
                generalResult.CreateGeneralResultFaultTreeIllustrationPointEntity();

            // Assert
            AssertGeneralResultFaultTreeIllustrationPointEntity(generalResult, entity);
        }
        public void Create_ValidTopLevelFaultTreeIllustrationPointWithChildren_ReturnsTopLevelFaultTreeIllustrationPointEntityWithChildren()
        {
            // Setup
            var random = new Random(21);

            var windDirection         = new WindDirection("WindDirection Name", random.NextDouble());
            var illustrationPointNode = new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPoint());

            illustrationPointNode.SetChildren(new[]
            {
                new IllustrationPointNode(new TestSubMechanismIllustrationPoint("Point A")),
                new IllustrationPointNode(new TestSubMechanismIllustrationPoint("Point B"))
            });

            var topLevelIllustrationPoint = new TopLevelFaultTreeIllustrationPoint(
                windDirection,
                "Just a situation",
                illustrationPointNode);
            int order = random.Next();

            // Call
            TopLevelFaultTreeIllustrationPointEntity entity = topLevelIllustrationPoint.Create(order);

            // Assert
            TestHelper.AssertAreEqualButNotSame(topLevelIllustrationPoint.ClosingSituation, entity.ClosingSituation);
            TestHelper.AssertAreEqualButNotSame(windDirection.Name, entity.WindDirectionName);
            Assert.AreEqual(windDirection.Angle, entity.WindDirectionAngle, windDirection.Angle.GetAccuracy());
            Assert.AreEqual(order, entity.Order);

            SubMechanismIllustrationPointEntity[] subMechanismIllustrationPointEntities =
                entity.FaultTreeIllustrationPointEntity.SubMechanismIllustrationPointEntities.ToArray();
            Assert.AreEqual(2, subMechanismIllustrationPointEntities.Length);

            for (var i = 0; i < 2; i++)
            {
                var expectedIllustrationPoint = new TestSubMechanismIllustrationPoint(subMechanismIllustrationPointEntities[i].Name);
                SubMechanismIllustrationPointEntity illustrationPointEntity = subMechanismIllustrationPointEntities[i];
                Assert.AreEqual(expectedIllustrationPoint.Name, illustrationPointEntity.Name);
                Assert.AreEqual(expectedIllustrationPoint.Beta, illustrationPointEntity.Beta, expectedIllustrationPoint.Beta.GetAccuracy());
                Assert.AreEqual(expectedIllustrationPoint.IllustrationPointResults.Count(),
                                illustrationPointEntity.IllustrationPointResultEntities.Count);
                Assert.AreEqual(expectedIllustrationPoint.Stochasts.Count(),
                                illustrationPointEntity.IllustrationPointResultEntities.Count);
                Assert.AreEqual(i, illustrationPointEntity.Order);
            }
        }
        public void Create_ValidTopLevelFaultTreeIllustrationPoint_ReturnsTopLevelFaultTreeIllustrationPointEntity()
        {
            // Setup
            var random = new Random(21);

            var windDirection     = new WindDirection("WindDirection Name", random.NextDouble());
            var illustrationPoint = new TopLevelFaultTreeIllustrationPoint(
                windDirection,
                "Just a situation",
                new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPoint()));
            int order = random.Next();

            // Call
            TopLevelFaultTreeIllustrationPointEntity entity = illustrationPoint.Create(order);

            // Assert
            TestHelper.AssertAreEqualButNotSame(illustrationPoint.ClosingSituation, entity.ClosingSituation);
            TestHelper.AssertAreEqualButNotSame(windDirection.Name, entity.WindDirectionName);
            Assert.AreEqual(windDirection.Angle, entity.WindDirectionAngle, windDirection.Angle.GetAccuracy());
            CollectionAssert.IsEmpty(entity.FaultTreeIllustrationPointEntity.SubMechanismIllustrationPointEntities);
            CollectionAssert.IsEmpty(entity.FaultTreeIllustrationPointEntity.FaultTreeIllustrationPointEntity1);
            Assert.AreEqual(order, entity.Order);
        }