Beispiel #1
0
        public void Read_CollectorNull_ThrowsArgumentNullException()
        {
            // Setup
            var entity = new HydraulicLocationCalculationForTargetProbabilityCollectionEntity();

            // Call
            void Call() => entity.Read(null);

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

            Assert.AreEqual("collector", exception.ParamName);
        }
Beispiel #2
0
 private static HydraulicBoundaryLocationCalculationsForTargetProbability GetHydraulicBoundaryLocationCalculationsForTargetProbabilityValue(
     HydraulicLocationCalculationForTargetProbabilityCollectionEntity hydraulicLocationCalculationForTargetProbabilityCollectionEntity,
     ReadConversionCollector collector)
 {
     return(hydraulicLocationCalculationForTargetProbabilityCollectionEntity?.Read(collector));
 }
Beispiel #3
0
        public void Read_EntityWithValidValues_SetsCalculationsWithExpectedValues()
        {
            // Setup
            var random = new Random(21);

            HydraulicLocationEntity hydraulicLocationEntityOne = HydraulicLocationEntityTestFactory.CreateHydraulicLocationEntity();
            var calculationEntityWithoutOutput = new HydraulicLocationCalculationEntity
            {
                HydraulicLocationEntity = hydraulicLocationEntityOne,
                ShouldIllustrationPointsBeCalculated = Convert.ToByte(random.NextBoolean())
            };

            HydraulicLocationEntity hydraulicLocationEntityTwo = HydraulicLocationEntityTestFactory.CreateHydraulicLocationEntity();
            var calculationEntityWithOutput = new HydraulicLocationCalculationEntity
            {
                HydraulicLocationEntity = hydraulicLocationEntityTwo,
                ShouldIllustrationPointsBeCalculated = Convert.ToByte(random.NextBoolean()),
                HydraulicLocationOutputEntities      =
                {
                    new HydraulicLocationOutputEntity()
                }
            };

            var collectionEntity = new HydraulicLocationCalculationForTargetProbabilityCollectionEntity
            {
                TargetProbability = random.NextDouble(0, 0.1),
                HydraulicLocationCalculationEntities =
                {
                    calculationEntityWithoutOutput,
                    calculationEntityWithOutput
                }
            };

            var hydraulicBoundaryLocationOne = new TestHydraulicBoundaryLocation("1");
            var hydraulicBoundaryLocationTwo = new TestHydraulicBoundaryLocation("2");
            var collector = new ReadConversionCollector();

            collector.Read(hydraulicLocationEntityOne, hydraulicBoundaryLocationOne);
            collector.Read(hydraulicLocationEntityTwo, hydraulicBoundaryLocationTwo);

            // Call
            HydraulicBoundaryLocationCalculationsForTargetProbability calculations = collectionEntity.Read(collector);

            // Assert
            Assert.AreEqual(collectionEntity.TargetProbability, calculations.TargetProbability);

            IEnumerable <HydraulicBoundaryLocationCalculation> hydraulicBoundaryLocationCalculations = calculations.HydraulicBoundaryLocationCalculations;

            Assert.AreEqual(collectionEntity.HydraulicLocationCalculationEntities.Count, hydraulicBoundaryLocationCalculations.Count());

            HydraulicBoundaryLocationCalculation calculationOne = hydraulicBoundaryLocationCalculations.ElementAt(0);

            Assert.AreEqual(Convert.ToBoolean(calculationEntityWithoutOutput.ShouldIllustrationPointsBeCalculated),
                            calculationOne.InputParameters.ShouldIllustrationPointsBeCalculated);
            Assert.AreSame(hydraulicBoundaryLocationOne, calculationOne.HydraulicBoundaryLocation);
            Assert.IsNull(calculationOne.Output);

            HydraulicBoundaryLocationCalculation calculationTwo = hydraulicBoundaryLocationCalculations.ElementAt(1);

            Assert.AreEqual(Convert.ToBoolean(calculationEntityWithOutput.ShouldIllustrationPointsBeCalculated),
                            calculationTwo.InputParameters.ShouldIllustrationPointsBeCalculated);
            Assert.AreSame(hydraulicBoundaryLocationTwo, calculationTwo.HydraulicBoundaryLocation);
            Assert.IsNotNull(calculationTwo.Output);
        }
Beispiel #4
0
        public void Read_SameHydraulicLocationCalculationForTargetProbabilityCollectionEntityTwice_ReturnsSameHydraulicBoundaryLocationCalculationsForTargetProbability()
        {
            // Setup
            var random           = new Random(21);
            var collectionEntity = new HydraulicLocationCalculationForTargetProbabilityCollectionEntity
            {
                TargetProbability = random.NextDouble(0, 0.1)
            };

            var collector = new ReadConversionCollector();

            // Call
            HydraulicBoundaryLocationCalculationsForTargetProbability calculationsOne = collectionEntity.Read(collector);
            HydraulicBoundaryLocationCalculationsForTargetProbability calculationsTwo = collectionEntity.Read(collector);

            // Assert
            Assert.AreSame(calculationsOne, calculationsTwo);
        }