Example #1
0
        public void CopyProperties_FromStructureNull_ThrowsArgumentNullException()
        {
            // Setup
            var structure = new ClosingStructure(new ClosingStructure.ConstructionProperties
            {
                Name     = "aName",
                Id       = "anId",
                Location = new Point2D(0, 0)
            });

            // Call
            TestDelegate call = () => structure.CopyProperties(null);

            // Assert
            string paramName = Assert.Throws <ArgumentNullException>(call).ParamName;

            Assert.AreEqual("fromStructure", paramName);
        }
Example #2
0
        public void CopyProperties_FromStructure_UpdatesProperties()
        {
            // Setup
            var random    = new Random(123);
            var structure = new ClosingStructure(new ClosingStructure.ConstructionProperties
            {
                Name     = "aName",
                Id       = "anId",
                Location = new Point2D(0, 0)
            });

            var otherStructure = new ClosingStructure(new ClosingStructure.ConstructionProperties
            {
                Name     = "otherName",
                Id       = "otherId",
                Location = new Point2D(1, 1),
                StructureNormalOrientation  = random.NextRoundedDouble(),
                AllowedLevelIncreaseStorage =
                {
                    Mean              = random.NextRoundedDouble(),
                    StandardDeviation = random.NextRoundedDouble()
                },
                AreaFlowApertures =
                {
                    Mean              = random.NextRoundedDouble(),
                    StandardDeviation = random.NextRoundedDouble()
                },
                CriticalOvertoppingDischarge =
                {
                    Mean                   = random.NextRoundedDouble(),
                    CoefficientOfVariation = random.NextRoundedDouble()
                },
                FlowWidthAtBottomProtection =
                {
                    Mean              = random.NextRoundedDouble(),
                    StandardDeviation = random.NextRoundedDouble()
                },
                InsideWaterLevel =
                {
                    Mean              = random.NextRoundedDouble(),
                    StandardDeviation = random.NextRoundedDouble()
                },
                LevelCrestStructureNotClosing =
                {
                    Mean              = random.NextRoundedDouble(),
                    StandardDeviation = random.NextRoundedDouble()
                },
                StorageStructureArea =
                {
                    Mean                   = random.NextRoundedDouble(),
                    CoefficientOfVariation = random.NextRoundedDouble()
                },
                ThresholdHeightOpenWeir =
                {
                    Mean              = random.NextRoundedDouble(),
                    StandardDeviation = random.NextRoundedDouble()
                },
                WidthFlowApertures =
                {
                    Mean              = random.NextRoundedDouble(),
                    StandardDeviation = random.NextRoundedDouble()
                },
                FailureProbabilityOpenStructure = random.NextDouble(),
                FailureProbabilityReparation    = random.NextDouble(),
                InflowModelType    = ClosingStructureInflowModelType.FloodedCulvert,
                IdenticalApertures = random.Next(),
                ProbabilityOpenStructureBeforeFlooding = random.NextDouble()
            });

            // Call
            structure.CopyProperties(otherStructure);

            // Assert
            Assert.AreNotEqual(otherStructure.Id, structure.Id);
            Assert.AreEqual(otherStructure.Name, structure.Name);
            TestHelper.AssertAreEqualButNotSame(otherStructure.Location, structure.Location);
            Assert.AreEqual(otherStructure.StructureNormalOrientation, structure.StructureNormalOrientation);
            TestHelper.AssertAreEqualButNotSame(otherStructure.AllowedLevelIncreaseStorage, structure.AllowedLevelIncreaseStorage);
            TestHelper.AssertAreEqualButNotSame(otherStructure.AreaFlowApertures, structure.AreaFlowApertures);
            TestHelper.AssertAreEqualButNotSame(otherStructure.CriticalOvertoppingDischarge, structure.CriticalOvertoppingDischarge);
            Assert.AreEqual(otherStructure.FailureProbabilityOpenStructure, structure.FailureProbabilityOpenStructure);
            Assert.AreEqual(otherStructure.FailureProbabilityReparation, structure.FailureProbabilityReparation);
            Assert.AreEqual(otherStructure.IdenticalApertures, structure.IdenticalApertures);
            Assert.AreEqual(otherStructure.ProbabilityOpenStructureBeforeFlooding, structure.ProbabilityOpenStructureBeforeFlooding);
            TestHelper.AssertAreEqualButNotSame(otherStructure.FlowWidthAtBottomProtection, structure.FlowWidthAtBottomProtection);
            TestHelper.AssertAreEqualButNotSame(otherStructure.InsideWaterLevel, structure.InsideWaterLevel);
            TestHelper.AssertAreEqualButNotSame(otherStructure.LevelCrestStructureNotClosing, structure.LevelCrestStructureNotClosing);
            TestHelper.AssertAreEqualButNotSame(otherStructure.StorageStructureArea, structure.StorageStructureArea);
            TestHelper.AssertAreEqualButNotSame(otherStructure.ThresholdHeightOpenWeir, structure.ThresholdHeightOpenWeir);
            TestHelper.AssertAreEqualButNotSame(otherStructure.WidthFlowApertures, structure.WidthFlowApertures);
        }