public void Create_CalculationWithoutOutput_ReturnsHydraulicLocationCalculationEntity()
        {
            // Setup
            var  random = new Random(33);
            bool shouldIllustrationPointsBeCalculated = random.NextBoolean();

            var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();
            var calculation = new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation)
            {
                InputParameters =
                {
                    ShouldIllustrationPointsBeCalculated = shouldIllustrationPointsBeCalculated
                },
                Output = null
            };

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

            registry.Register(hydraulicLocationEntity, hydraulicBoundaryLocation);

            // Call
            HydraulicLocationCalculationEntity entity = calculation.Create(registry);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual(Convert.ToByte(shouldIllustrationPointsBeCalculated), entity.ShouldIllustrationPointsBeCalculated);
            Assert.IsEmpty(entity.HydraulicLocationOutputEntities);
        }
        public void Create_RegistryNull_ThrowsArgumentNullException()
        {
            // Setup
            var calculation = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation());

            // Call
            TestDelegate call = () => calculation.Create(null);

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

            Assert.AreEqual("registry", exception.ParamName);
        }
        public void Create_CalculationWithAlreadyCreatedHydraulicBoundaryLocation_ReturnsEntityWithHydraulicBoundaryLocationEntity()
        {
            // Setup
            var hydraulicLocation = new TestHydraulicBoundaryLocation();

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

            registry.Register(hydraulicLocationEntity, hydraulicLocation);

            var calculation = new HydraulicBoundaryLocationCalculation(hydraulicLocation);

            // Call
            HydraulicLocationCalculationEntity entity = calculation.Create(registry);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreSame(hydraulicLocationEntity, entity.HydraulicLocationEntity);
        }
        public void Create_CalculationWithOutput_ReturnsHydraulicLocationCalculationEntityWithOutput()
        {
            // Setup
            var  random = new Random(33);
            bool shouldIllustrationPointsBeCalculated = random.NextBoolean();

            var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();
            var calculation = new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation)
            {
                InputParameters =
                {
                    ShouldIllustrationPointsBeCalculated = shouldIllustrationPointsBeCalculated
                },
                Output = new HydraulicBoundaryLocationCalculationOutput(
                    random.NextDouble(), random.NextDouble(), random.NextDouble(), random.NextDouble(),
                    random.NextDouble(), random.NextEnumValue <CalculationConvergence>(),
                    null)
            };

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

            registry.Register(hydraulicLocationEntity, hydraulicBoundaryLocation);

            // Call
            HydraulicLocationCalculationEntity entity = calculation.Create(registry);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual(Convert.ToByte(shouldIllustrationPointsBeCalculated), entity.ShouldIllustrationPointsBeCalculated);

            HydraulicLocationOutputEntity outputEntity = entity.HydraulicLocationOutputEntities.Single();

            HydraulicBoundaryLocationCalculationOutput expectedOutput = calculation.Output;

            Assert.AreEqual(expectedOutput.CalculatedProbability, outputEntity.CalculatedProbability);
            Assert.AreEqual(expectedOutput.CalculatedReliability, outputEntity.CalculatedReliability);
            Assert.AreEqual(expectedOutput.TargetReliability, outputEntity.TargetReliability);
            Assert.AreEqual(expectedOutput.TargetProbability, outputEntity.TargetProbability);
            Assert.IsNull(outputEntity.GeneralResultSubMechanismIllustrationPointEntity);
            Assert.AreEqual(Convert.ToByte(expectedOutput.CalculationConvergence), outputEntity.CalculationConvergence);
        }