コード例 #1
0
        public void Create_GroupWithChildClosingStructuresCalculationsAndChildCalculationGroups_CreateEntities()
        {
            // Setup
            var group = new CalculationGroup
            {
                Children =
                {
                    new CalculationGroup
                    {
                        Name = "A"
                    },
                    new StructuresCalculationScenario <ClosingStructuresInput>
                    {
                        Name = "B"
                    },
                    new CalculationGroup
                    {
                        Name = "C"
                    },
                    new StructuresCalculationScenario <ClosingStructuresInput>
                    {
                        Name = "D"
                    }
                }
            };

            var registry = new PersistenceRegistry();

            // Call
            CalculationGroupEntity entity = group.Create(registry, 0);

            // Assert
            CalculationGroupEntity[]             childGroupEntities       = entity.CalculationGroupEntity1.ToArray();
            ClosingStructuresCalculationEntity[] childCalculationEntities = entity.ClosingStructuresCalculationEntities.ToArray();
            Assert.AreEqual(2, childGroupEntities.Length);
            Assert.AreEqual(2, childCalculationEntities.Length);

            CalculationGroupEntity childEntity1 = childGroupEntities[0];

            Assert.AreEqual("A", childEntity1.Name);
            Assert.AreEqual(0, childEntity1.Order);
            CollectionAssert.IsEmpty(childEntity1.CalculationGroupEntity1);

            ClosingStructuresCalculationEntity childEntity2 = childCalculationEntities[0];

            Assert.AreEqual("B", childEntity2.Name);
            Assert.AreEqual(1, childEntity2.Order);

            CalculationGroupEntity childEntity3 = childGroupEntities[1];

            Assert.AreEqual("C", childEntity3.Name);
            Assert.AreEqual(2, childEntity3.Order);
            CollectionAssert.IsEmpty(childEntity3.CalculationGroupEntity1);

            ClosingStructuresCalculationEntity childEntity4 = childCalculationEntities[1];

            Assert.AreEqual("D", childEntity4.Name);
            Assert.AreEqual(3, childEntity4.Order);
        }
コード例 #2
0
        public void Create_RegistryIsNull_ThrowArgumentNullException()
        {
            // Setup
            var group = new CalculationGroup();

            // Call
            void Call() => group.Create(null, 0);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("registry", exception.ParamName);
        }
コード例 #3
0
        public void Create_StringPropertiesDoNotShareReference()
        {
            // Setup
            const string name  = "original";
            var          group = new CalculationGroup
            {
                Name = name
            };

            var registry = new PersistenceRegistry();

            // Call
            CalculationGroupEntity entity = group.Create(registry, 0);

            // Assert
            Assert.AreNotSame(name, entity.Name,
                              "To create stable binary representations/fingerprints, it's really important that strings are not shared.");
            Assert.AreEqual(name, entity.Name);
        }
コード例 #4
0
        public void Create_GroupWithoutChildren_CreateEntity(int order)
        {
            // Setup
            const string name  = "blaballab";
            var          group = new CalculationGroup
            {
                Name = name
            };

            var registry = new PersistenceRegistry();

            // Call
            CalculationGroupEntity entity = group.Create(registry, order);

            // Assert
            Assert.AreEqual(name, entity.Name);
            Assert.AreEqual(order, entity.Order);

            CollectionAssert.IsEmpty(entity.CalculationGroupEntity1);
            CollectionAssert.IsEmpty(entity.FailureMechanismEntities);
            Assert.IsNull(entity.CalculationGroupEntity2);
        }
コード例 #5
0
        public void Create_GroupWithMacroStabilityInwardsCalculations_CreatesEntities()
        {
            // Setup
            var group = new CalculationGroup
            {
                Children =
                {
                    new MacroStabilityInwardsCalculationScenario
                    {
                        Name = "A"
                    },
                    new MacroStabilityInwardsCalculationScenario
                    {
                        Name = "B"
                    }
                }
            };

            var registry = new PersistenceRegistry();

            // Call
            CalculationGroupEntity entity = group.Create(registry, 0);

            // Assert
            MacroStabilityInwardsCalculationEntity[] childCalculationEntities = entity.MacroStabilityInwardsCalculationEntities.ToArray();
            Assert.AreEqual(2, childCalculationEntities.Length);

            MacroStabilityInwardsCalculationEntity childEntity1 = childCalculationEntities[0];

            Assert.AreEqual("A", childEntity1.Name);
            Assert.AreEqual(0, childEntity1.Order);

            MacroStabilityInwardsCalculationEntity childEntity2 = childCalculationEntities[1];

            Assert.AreEqual("B", childEntity2.Name);
            Assert.AreEqual(1, childEntity2.Order);
        }
コード例 #6
0
        public void Create_GroupWithChildWaveImpactAsphaltCoverWaveConditionsCalculations_CreateEntities()
        {
            // Setup
            var group = new CalculationGroup
            {
                Children =
                {
                    new WaveImpactAsphaltCoverWaveConditionsCalculation
                    {
                        Name = "A"
                    },
                    new WaveImpactAsphaltCoverWaveConditionsCalculation
                    {
                        Name = "B"
                    }
                }
            };

            var registry = new PersistenceRegistry();

            // Call
            CalculationGroupEntity entity = group.Create(registry, 0);

            // Assert
            WaveImpactAsphaltCoverWaveConditionsCalculationEntity[] childCalculationEntities = entity.WaveImpactAsphaltCoverWaveConditionsCalculationEntities.ToArray();
            Assert.AreEqual(2, childCalculationEntities.Length);

            WaveImpactAsphaltCoverWaveConditionsCalculationEntity childEntity1 = childCalculationEntities[0];

            Assert.AreEqual("A", childEntity1.Name);
            Assert.AreEqual(0, childEntity1.Order);
            WaveImpactAsphaltCoverWaveConditionsCalculationEntity childEntity2 = childCalculationEntities[1];

            Assert.AreEqual("B", childEntity2.Name);
            Assert.AreEqual(1, childEntity2.Order);
        }
コード例 #7
0
        public void Create_GroupWithChildHeightStructuresCalculations_CreateEntities()
        {
            // Setup
            var group = new CalculationGroup
            {
                Children =
                {
                    new StructuresCalculationScenario <HeightStructuresInput>
                    {
                        Name = "A"
                    },
                    new StructuresCalculationScenario <HeightStructuresInput>
                    {
                        Name = "B"
                    }
                }
            };

            var registry = new PersistenceRegistry();

            // Call
            CalculationGroupEntity entity = group.Create(registry, 0);

            // Assert
            HeightStructuresCalculationEntity[] childCalculationEntities = entity.HeightStructuresCalculationEntities.ToArray();
            Assert.AreEqual(2, childCalculationEntities.Length);

            HeightStructuresCalculationEntity childEntity1 = childCalculationEntities[0];

            Assert.AreEqual("A", childEntity1.Name);
            Assert.AreEqual(0, childEntity1.Order);
            HeightStructuresCalculationEntity childEntity2 = childCalculationEntities[1];

            Assert.AreEqual("B", childEntity2.Name);
            Assert.AreEqual(1, childEntity2.Order);
        }
コード例 #8
0
        public void Create_GroupWithChildProbabilisticPipingCalculations_CreateEntities()
        {
            // Setup
            var group = new CalculationGroup
            {
                Children =
                {
                    new ProbabilisticPipingCalculationScenario
                    {
                        Name = "A"
                    },
                    new ProbabilisticPipingCalculationScenario
                    {
                        Name = "B"
                    }
                }
            };

            var registry = new PersistenceRegistry();

            // Call
            CalculationGroupEntity entity = group.Create(registry, 0);

            // Assert
            ProbabilisticPipingCalculationEntity[] probabilisticChildCalculationEntities = entity.ProbabilisticPipingCalculationEntities.ToArray();
            Assert.AreEqual(2, probabilisticChildCalculationEntities.Length);

            ProbabilisticPipingCalculationEntity childEntity1 = probabilisticChildCalculationEntities[0];

            Assert.AreEqual("A", childEntity1.Name);
            Assert.AreEqual(0, childEntity1.Order);
            ProbabilisticPipingCalculationEntity childEntity2 = probabilisticChildCalculationEntities[1];

            Assert.AreEqual("B", childEntity2.Name);
            Assert.AreEqual(1, childEntity2.Order);
        }
コード例 #9
0
        public void Create_GroupWithChildPipingCalculationsAndChildCalculationGroups_CreateEntities()
        {
            // Setup
            var group = new CalculationGroup
            {
                Children =
                {
                    new CalculationGroup
                    {
                        Name = "A"
                    },
                    new SemiProbabilisticPipingCalculationScenario
                    {
                        Name = "B"
                    },
                    new ProbabilisticPipingCalculationScenario
                    {
                        Name = "C"
                    },
                    new CalculationGroup
                    {
                        Name = "D"
                    },
                    new SemiProbabilisticPipingCalculationScenario
                    {
                        Name = "E"
                    },
                    new ProbabilisticPipingCalculationScenario
                    {
                        Name = "F"
                    }
                }
            };

            var registry = new PersistenceRegistry();

            // Call
            CalculationGroupEntity entity = group.Create(registry, 0);

            // Assert
            CalculationGroupEntity[] childGroupEntities = entity.CalculationGroupEntity1.ToArray();
            SemiProbabilisticPipingCalculationEntity[] semiProbabilisticChildCalculationEntities = entity.SemiProbabilisticPipingCalculationEntities.ToArray();
            ProbabilisticPipingCalculationEntity[]     probabilisticChildCalculationEntities     = entity.ProbabilisticPipingCalculationEntities.ToArray();

            Assert.AreEqual(2, childGroupEntities.Length);
            Assert.AreEqual(2, semiProbabilisticChildCalculationEntities.Length);
            Assert.AreEqual(2, probabilisticChildCalculationEntities.Length);

            CalculationGroupEntity childEntity1 = childGroupEntities[0];

            Assert.AreEqual("A", childEntity1.Name);
            Assert.AreEqual(0, childEntity1.Order);
            CollectionAssert.IsEmpty(childEntity1.CalculationGroupEntity1);

            SemiProbabilisticPipingCalculationEntity childEntity2 = semiProbabilisticChildCalculationEntities[0];

            Assert.AreEqual("B", childEntity2.Name);
            Assert.AreEqual(1, childEntity2.Order);

            ProbabilisticPipingCalculationEntity childEntity3 = probabilisticChildCalculationEntities[0];

            Assert.AreEqual("C", childEntity3.Name);
            Assert.AreEqual(2, childEntity3.Order);

            CalculationGroupEntity childEntity4 = childGroupEntities[1];

            Assert.AreEqual("D", childEntity4.Name);
            Assert.AreEqual(3, childEntity4.Order);
            CollectionAssert.IsEmpty(childEntity4.CalculationGroupEntity1);

            SemiProbabilisticPipingCalculationEntity childEntity5 = semiProbabilisticChildCalculationEntities[1];

            Assert.AreEqual("E", childEntity5.Name);
            Assert.AreEqual(4, childEntity5.Order);

            ProbabilisticPipingCalculationEntity childEntity6 = probabilisticChildCalculationEntities[1];

            Assert.AreEqual("F", childEntity6.Name);
            Assert.AreEqual(5, childEntity6.Order);
        }
コード例 #10
0
        public void Create_GroupWithChildren_CreateEntities()
        {
            // Setup
            const string name  = "blaballab";
            var          group = new CalculationGroup
            {
                Name = name
            };

            group.Children.Add(new CalculationGroup
            {
                Name     = "A",
                Children =
                {
                    new CalculationGroup
                    {
                        Name = "AA"
                    },
                    new CalculationGroup
                    {
                        Name = "AB"
                    }
                }
            });
            group.Children.Add(new CalculationGroup
            {
                Name = "B"
            });

            var registry = new PersistenceRegistry();

            // Call
            CalculationGroupEntity entity = group.Create(registry, 0);

            // Assert
            Assert.AreEqual(name, entity.Name);
            Assert.AreEqual(0, entity.Order);

            CalculationGroupEntity[] childGroupEntities = entity.CalculationGroupEntity1.ToArray();
            Assert.AreEqual(2, childGroupEntities.Length);

            CalculationGroupEntity childEntity1 = childGroupEntities[0];

            Assert.AreEqual("A", childEntity1.Name);
            Assert.AreEqual(0, childEntity1.Order);
            Assert.AreEqual(2, childEntity1.CalculationGroupEntity1.Count);
            CalculationGroupEntity childEntity1ChildEntity1 = childEntity1.CalculationGroupEntity1.ElementAt(0);

            Assert.AreEqual("AA", childEntity1ChildEntity1.Name);
            Assert.AreEqual(0, childEntity1ChildEntity1.Order);
            CollectionAssert.IsEmpty(childEntity1ChildEntity1.CalculationGroupEntity1);
            CalculationGroupEntity childEntity1ChildEntity2 = childEntity1.CalculationGroupEntity1.ElementAt(1);

            Assert.AreEqual("AB", childEntity1ChildEntity2.Name);
            Assert.AreEqual(1, childEntity1ChildEntity2.Order);
            CollectionAssert.IsEmpty(childEntity1ChildEntity2.CalculationGroupEntity1);

            CalculationGroupEntity childEntity2 = childGroupEntities[1];

            Assert.AreEqual("B", childEntity2.Name);
            Assert.AreEqual(1, childEntity2.Order);
            CollectionAssert.IsEmpty(childEntity2.CalculationGroupEntity1);
        }