Пример #1
0
        public void Read_ReadConversionCollectorNull_ThrowArgumentNullException()
        {
            // Setup
            var entity = new HeightStructureEntity();

            // Call
            TestDelegate call = () => entity.Read(null);

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

            Assert.AreEqual("collector", paramName);
        }
Пример #2
0
        public void Read_ValidEntity_ReturnHeightStructure()
        {
            // Setup
            var entity = new HeightStructureEntity
            {
                Name = "A",
                Id   = "B",
                X    = 1.1,
                Y    = 2.2,
                StructureNormalOrientation                         = 3.3,
                LevelCrestStructureMean                            = 4.4,
                LevelCrestStructureStandardDeviation               = 5.5,
                FlowWidthAtBottomProtectionMean                    = 6.6,
                FlowWidthAtBottomProtectionStandardDeviation       = 7.7,
                CriticalOvertoppingDischargeMean                   = 8.8,
                CriticalOvertoppingDischargeCoefficientOfVariation = 9.9,
                WidthFlowAperturesMean = 10.10,
                WidthFlowAperturesStandardDeviation    = 11.11,
                FailureProbabilityStructureWithErosion = 12.12,
                StorageStructureAreaMean = 13.13,
                StorageStructureAreaCoefficientOfVariation   = 14.14,
                AllowedLevelIncreaseStorageMean              = 15.15,
                AllowedLevelIncreaseStorageStandardDeviation = 16.16
            };

            var collector = new ReadConversionCollector();

            // Call
            HeightStructure structure = entity.Read(collector);

            // Assert
            Assert.AreEqual(entity.Name, structure.Name);
            Assert.AreEqual(entity.Id, structure.Id);
            Assert.AreEqual(entity.X, structure.Location.X);
            Assert.AreEqual(entity.Y, structure.Location.Y);
            Assert.AreEqual(entity.StructureNormalOrientation, structure.StructureNormalOrientation.Value);

            Assert.AreEqual(entity.LevelCrestStructureMean, structure.LevelCrestStructure.Mean.Value);
            Assert.AreEqual(entity.LevelCrestStructureStandardDeviation, structure.LevelCrestStructure.StandardDeviation.Value);
            Assert.AreEqual(entity.FlowWidthAtBottomProtectionMean, structure.FlowWidthAtBottomProtection.Mean.Value);
            Assert.AreEqual(entity.FlowWidthAtBottomProtectionStandardDeviation, structure.FlowWidthAtBottomProtection.StandardDeviation.Value);
            Assert.AreEqual(entity.CriticalOvertoppingDischargeMean, structure.CriticalOvertoppingDischarge.Mean.Value);
            Assert.AreEqual(entity.CriticalOvertoppingDischargeCoefficientOfVariation, structure.CriticalOvertoppingDischarge.CoefficientOfVariation.Value);
            Assert.AreEqual(entity.WidthFlowAperturesMean, structure.WidthFlowApertures.Mean.Value);
            Assert.AreEqual(entity.WidthFlowAperturesStandardDeviation, structure.WidthFlowApertures.StandardDeviation.Value);
            Assert.AreEqual(entity.FailureProbabilityStructureWithErosion, structure.FailureProbabilityStructureWithErosion);
            Assert.AreEqual(entity.StorageStructureAreaMean, structure.StorageStructureArea.Mean.Value);
            Assert.AreEqual(entity.StorageStructureAreaCoefficientOfVariation, structure.StorageStructureArea.CoefficientOfVariation.Value);
            Assert.AreEqual(entity.AllowedLevelIncreaseStorageMean, structure.AllowedLevelIncreaseStorage.Mean.Value);
            Assert.AreEqual(entity.AllowedLevelIncreaseStorageStandardDeviation, structure.AllowedLevelIncreaseStorage.StandardDeviation.Value);
        }
Пример #3
0
        public void Read_NullValues_ReturnHeightStructureWithNaN()
        {
            // Setup
            var entity = new HeightStructureEntity
            {
                Name = "A",
                Id   = "B",
                X    = null,
                Y    = null,
                StructureNormalOrientation                         = null,
                LevelCrestStructureMean                            = null,
                LevelCrestStructureStandardDeviation               = null,
                FlowWidthAtBottomProtectionMean                    = null,
                FlowWidthAtBottomProtectionStandardDeviation       = null,
                CriticalOvertoppingDischargeMean                   = null,
                CriticalOvertoppingDischargeCoefficientOfVariation = null,
                WidthFlowAperturesMean = null,
                WidthFlowAperturesStandardDeviation    = null,
                FailureProbabilityStructureWithErosion = null,
                StorageStructureAreaMean = null,
                StorageStructureAreaCoefficientOfVariation   = null,
                AllowedLevelIncreaseStorageMean              = null,
                AllowedLevelIncreaseStorageStandardDeviation = null
            };

            var collector = new ReadConversionCollector();

            // Call
            HeightStructure structure = entity.Read(collector);

            // Assert
            Assert.IsNaN(structure.Location.X);
            Assert.IsNaN(structure.Location.Y);
            Assert.IsNaN(structure.StructureNormalOrientation);

            Assert.IsNaN(structure.LevelCrestStructure.Mean.Value);
            Assert.IsNaN(structure.LevelCrestStructure.StandardDeviation.Value);
            Assert.IsNaN(structure.FlowWidthAtBottomProtection.Mean.Value);
            Assert.IsNaN(structure.FlowWidthAtBottomProtection.StandardDeviation.Value);
            Assert.IsNaN(structure.CriticalOvertoppingDischarge.Mean.Value);
            Assert.IsNaN(structure.CriticalOvertoppingDischarge.CoefficientOfVariation.Value);
            Assert.IsNaN(structure.WidthFlowApertures.Mean.Value);
            Assert.IsNaN(structure.WidthFlowApertures.StandardDeviation.Value);
            Assert.IsNaN(structure.FailureProbabilityStructureWithErosion);
            Assert.IsNaN(structure.StorageStructureArea.Mean.Value);
            Assert.IsNaN(structure.StorageStructureArea.CoefficientOfVariation.Value);
            Assert.IsNaN(structure.AllowedLevelIncreaseStorage.Mean.Value);
            Assert.IsNaN(structure.AllowedLevelIncreaseStorage.StandardDeviation.Value);
        }
Пример #4
0
        public void Read_EntityRegistered_ReturnRegisteredStructure()
        {
            // Setup
            var             entity = new HeightStructureEntity();
            HeightStructure registeredStructure = new TestHeightStructure();
            var             collector           = new ReadConversionCollector();

            collector.Read(entity, registeredStructure);

            // Call
            HeightStructure readStructure = entity.Read(collector);

            // Assert
            Assert.AreSame(registeredStructure, readStructure);
        }
Пример #5
0
        public void Read_EntityNotReadBefore_RegisterEntity()
        {
            // Setup
            var entity = new HeightStructureEntity
            {
                Name = "name",
                Id   = "id"
            };

            var collector = new ReadConversionCollector();

            // Precondition
            Assert.IsFalse(collector.Contains(entity));

            // Call
            HeightStructure calculation = entity.Read(collector);

            // Assert
            Assert.IsTrue(collector.Contains(entity));
            Assert.AreSame(calculation, collector.Get(entity));
        }