Exemplo n.º 1
0
        public void Create_HydraulicLocationCalculationForTargetProbabilitySavedMultipleTimes_ReturnsSameEntity()
        {
            // Setup
            var random       = new Random(21);
            var calculations = new HydraulicBoundaryLocationCalculationsForTargetProbability(random.NextDouble(0, 0.1));

            var registry = new PersistenceRegistry();

            // Call
            HydraulicLocationCalculationForTargetProbabilityCollectionEntity entityOne =
                calculations.Create(random.NextEnumValue <HydraulicBoundaryLocationCalculationType>(), random.Next(), registry);
            HydraulicLocationCalculationForTargetProbabilityCollectionEntity entityTwo =
                calculations.Create(random.NextEnumValue <HydraulicBoundaryLocationCalculationType>(), random.Next(), registry);

            // Assert
            Assert.AreSame(entityOne, entityTwo);
        }
Exemplo n.º 2
0
        public void Create_PersistenceRegistryNull_ThrowsArgumentNullException()
        {
            // Setup
            var random          = new Random(21);
            var calculationType = random.NextEnumValue <HydraulicBoundaryLocationCalculationType>();
            var calculations    = new HydraulicBoundaryLocationCalculationsForTargetProbability(random.NextDouble(0, 0.1));

            // Call
            void Call() => calculations.Create(calculationType, random.Next(), null);

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

            Assert.AreEqual("registry", exception.ParamName);
        }
Exemplo n.º 3
0
        public void Create_WithValidCollection_ReturnsEntityWithExpectedResults()
        {
            // Setup
            var random          = new Random(21);
            int order           = random.Next();
            var calculationType = random.NextEnumValue <HydraulicBoundaryLocationCalculationType>();

            var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();
            var calculation = new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation)
            {
                InputParameters =
                {
                    ShouldIllustrationPointsBeCalculated = random.NextBoolean()
                }
            };

            var calculations = new HydraulicBoundaryLocationCalculationsForTargetProbability(random.NextDouble(0, 0.1))
            {
                HydraulicBoundaryLocationCalculations =
                {
                    calculation
                }
            };

            var hydraulicLocationEntity = new HydraulicLocationEntity();
            var registry = new PersistenceRegistry();

            registry.Register(hydraulicLocationEntity, hydraulicBoundaryLocation);

            // Call
            HydraulicLocationCalculationForTargetProbabilityCollectionEntity entity = calculations.Create(calculationType, order, registry);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual(order, entity.Order);
            Assert.AreEqual(calculations.TargetProbability, entity.TargetProbability);
            Assert.AreEqual(Convert.ToByte(calculationType), entity.HydraulicBoundaryLocationCalculationType);

            HydraulicLocationCalculationEntity hydraulicLocationCalculationEntity = entity.HydraulicLocationCalculationEntities.Single();

            Assert.AreSame(hydraulicLocationEntity, hydraulicLocationCalculationEntity.HydraulicLocationEntity);
            Assert.AreEqual(Convert.ToByte(calculation.InputParameters.ShouldIllustrationPointsBeCalculated),
                            hydraulicLocationCalculationEntity.ShouldIllustrationPointsBeCalculated);
            CollectionAssert.IsEmpty(hydraulicLocationCalculationEntity.HydraulicLocationOutputEntities);
        }