Example #1
0
        private static DuneLocationCalculation CreateDuneLocationCalculation(DuneLocationCalculationEntity calculationEntity,
                                                                             ReadConversionCollector collector)
        {
            var calculation = new DuneLocationCalculation(collector.Get(calculationEntity.DuneLocationEntity));

            calculationEntity.Read(calculation);
            return(calculation);
        }
        public void Read_CalculationEntityWithOutput_SetsDuneLocationCalculationWithoutOutput()
        {
            // Setup
            var calculation = new DuneLocationCalculation(new TestDuneLocation());

            var entity = new DuneLocationCalculationEntity();

            // Call
            entity.Read(calculation);

            // Assert
            Assert.IsNull(calculation.Output);
        }
        public void Read_CalculationNull_ThrowsArgumentNullException()
        {
            // Setup
            var entity = new DuneLocationCalculationEntity();

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

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

            Assert.AreEqual("calculation", exception.ParamName);
        }
        public void Read_CalculationEntityWithOutput_SetsDuneLocationCalculationWithOutput()
        {
            // Setup
            var calculation = new DuneLocationCalculation(new TestDuneLocation());

            var    random                = new Random(21);
            double waterLevel            = random.NextDouble();
            double waveHeight            = random.NextDouble();
            double wavePeriod            = random.NextDouble();
            double targetProbability     = random.NextDouble();
            double targetReliability     = random.NextDouble();
            double calculatedProbability = random.NextDouble();
            double calculatedReliability = random.NextDouble();
            var    convergence           = random.NextEnumValue <CalculationConvergence>();

            var entity = new DuneLocationCalculationEntity
            {
                DuneLocationCalculationOutputEntities =
                {
                    new DuneLocationCalculationOutputEntity
                    {
                        WaterLevel             = waterLevel,
                        WaveHeight             = waveHeight,
                        WavePeriod             = wavePeriod,
                        TargetProbability      = targetProbability,
                        TargetReliability      = targetReliability,
                        CalculatedProbability  = calculatedProbability,
                        CalculatedReliability  = calculatedReliability,
                        CalculationConvergence = Convert.ToByte(convergence)
                    }
                }
            };

            // Call
            entity.Read(calculation);

            // Assert
            DuneLocationCalculationOutput output = calculation.Output;

            Assert.IsNotNull(output);
            Assert.AreEqual(waterLevel, output.WaterLevel, output.WaterLevel.GetAccuracy());
            Assert.AreEqual(waveHeight, output.WaveHeight, output.WaveHeight.GetAccuracy());
            Assert.AreEqual(wavePeriod, output.WavePeriod, output.WavePeriod.GetAccuracy());
            Assert.AreEqual(targetProbability, output.TargetProbability);
            Assert.AreEqual(targetReliability, output.TargetReliability, output.TargetReliability.GetAccuracy());
            Assert.AreEqual(calculatedProbability, output.CalculatedProbability);
            Assert.AreEqual(calculatedReliability, output.CalculatedReliability, output.CalculatedReliability.GetAccuracy());
            Assert.AreEqual(convergence, output.CalculationConvergence);
        }