public void Read_EntityWithNullValues_ReturnsCalculationScenarioWithNaNValues()
        {
            // Setup
            MacroStabilityInwardsCalculationEntity entity = CreateValidCalculationEntity();
            var collector = new ReadConversionCollector();

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

            // Assert
            Assert.IsNull(calculation.Output);
            Assert.IsNull(calculation.Comments.Body);

            MacroStabilityInwardsInput inputParameters = calculation.InputParameters;

            Assert.IsNull(inputParameters.StochasticSoilModel);
            Assert.IsNull(inputParameters.StochasticSoilProfile);
            Assert.IsNull(inputParameters.SurfaceLine);

            MacroStabilityInwardsCalculationEntityTestHelper.AssertCalculationScenarioPropertyValues(calculation, entity);
        }
        public void Read_EntityWithValidValues_ReturnsCalculationScenarioWithExpectedValues()
        {
            // Setup
            var random = new Random(21);
            var entity = new MacroStabilityInwardsCalculationEntity
            {
                Name            = "Calculation name",
                Comment         = "Comment here",
                AssessmentLevel = random.NextDouble(),
                UseAssessmentLevelManualInput = Convert.ToByte(random.NextBoolean()),
                ScenarioContribution          = random.NextDouble(),
                RelevantForScenario           = Convert.ToByte(random.NextBoolean()),
                SlipPlaneMinimumDepth         = random.NextDouble(),
                SlipPlaneMinimumLength        = random.NextDouble(),
                MaximumSliceWidth             = random.NextDouble(),
                MoveGrid                                = Convert.ToByte(random.NextBoolean()),
                DikeSoilScenario                        = Convert.ToByte(random.NextEnumValue <MacroStabilityInwardsDikeSoilScenario>()),
                WaterLevelRiverAverage                  = random.NextDouble(),
                DrainageConstructionPresent             = Convert.ToByte(random.NextBoolean()),
                DrainageConstructionCoordinateX         = random.NextDouble(),
                DrainageConstructionCoordinateZ         = random.NextDouble(),
                MinimumLevelPhreaticLineAtDikeTopRiver  = random.NextDouble(),
                MinimumLevelPhreaticLineAtDikeTopPolder = random.NextDouble(),
                LocationInputExtremeWaterLevelPolder    = random.NextDouble(),
                LocationInputExtremeUseDefaultOffsets   = Convert.ToByte(random.NextBoolean()),
                LocationInputExtremePhreaticLineOffsetBelowDikeTopAtRiver     = random.NextDouble(),
                LocationInputExtremePhreaticLineOffsetBelowDikeTopAtPolder    = random.NextDouble(),
                LocationInputExtremePhreaticLineOffsetBelowShoulderBaseInside = random.NextDouble(),
                LocationInputExtremePhreaticLineOffsetDikeToeAtPolder         = random.NextDouble(),
                LocationInputExtremePenetrationLength = random.NextDouble(),
                LocationInputDailyWaterLevelPolder    = random.NextDouble(),
                LocationInputDailyUseDefaultOffsets   = Convert.ToByte(random.NextBoolean()),
                LocationInputDailyPhreaticLineOffsetBelowDikeTopAtRiver     = random.NextDouble(),
                LocationInputDailyPhreaticLineOffsetBelowDikeTopAtPolder    = random.NextDouble(),
                LocationInputDailyPhreaticLineOffsetBelowShoulderBaseInside = random.NextDouble(),
                LocationInputDailyPhreaticLineOffsetDikeToeAtPolder         = random.NextDouble(),
                AdjustPhreaticLine3And4ForUplift     = Convert.ToByte(random.NextBoolean()),
                LeakageLengthOutwardsPhreaticLine4   = random.NextDouble(),
                LeakageLengthInwardsPhreaticLine4    = random.NextDouble(),
                LeakageLengthOutwardsPhreaticLine3   = random.NextDouble(),
                LeakageLengthInwardsPhreaticLine3    = random.NextDouble(),
                PiezometricHeadPhreaticLine2Outwards = random.NextDouble(),
                PiezometricHeadPhreaticLine2Inwards  = random.NextDouble(),
                GridDeterminationType        = Convert.ToByte(random.NextEnumValue <MacroStabilityInwardsGridDeterminationType>()),
                TangentLineDeterminationType = Convert.ToByte(random.NextEnumValue <MacroStabilityInwardsTangentLineDeterminationType>()),
                TangentLineZTop              = random.NextDouble(2.0, 3.0),
                TangentLineZBottom           = random.NextDouble(0.0, 1.0),
                TangentLineNumber            = random.Next(1, 50),
                LeftGridXLeft                = random.NextDouble(0.0, 1.0),
                LeftGridXRight               = random.NextDouble(2.0, 3.0),
                LeftGridNrOfHorizontalPoints = random.Next(1, 100),
                LeftGridZTop                  = random.NextDouble(2.0, 3.0),
                LeftGridZBottom               = random.NextDouble(0.0, 1.0),
                LeftGridNrOfVerticalPoints    = random.Next(1, 100),
                RightGridXLeft                = random.NextDouble(0.0, 1.0),
                RightGridXRight               = random.NextDouble(2.0, 3.0),
                RightGridNrOfHorizontalPoints = random.Next(1, 100),
                RightGridZTop                 = random.NextDouble(2.0, 3.0),
                RightGridZBottom              = random.NextDouble(0.0, 1.0),
                RightGridNrOfVerticalPoints   = random.Next(1, 100),
                CreateZones = Convert.ToByte(random.NextBoolean()),
                ZoningBoundariesDeterminationType = Convert.ToByte(random.NextEnumValue <MacroStabilityInwardsZoningBoundariesDeterminationType>()),
                ZoneBoundaryLeft  = random.NextDouble(),
                ZoneBoundaryRight = random.NextDouble()
            };

            var collector = new ReadConversionCollector();

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

            // Assert
            Assert.IsNull(calculation.Output);
            Assert.AreEqual(entity.Name, calculation.Name);
            Assert.AreEqual(entity.Comment, calculation.Comments.Body);

            MacroStabilityInwardsInput inputParameters = calculation.InputParameters;

            Assert.IsNull(inputParameters.StochasticSoilModel);
            Assert.IsNull(inputParameters.StochasticSoilProfile);
            Assert.IsNull(inputParameters.SurfaceLine);

            MacroStabilityInwardsCalculationEntityTestHelper.AssertCalculationScenarioPropertyValues(calculation, entity);
        }
        public void Create_MacroStabilityInwardsCalculationScenarioWithNumericAndBooleanPropertiesSet_ReturnsMacroStabilityInwardsCalculationEntity()
        {
            // Setup
            var random   = new Random(21);
            var scenario = new MacroStabilityInwardsCalculationScenario
            {
                IsRelevant      = random.NextBoolean(),
                Contribution    = random.NextRoundedDouble(),
                InputParameters =
                {
                    UseAssessmentLevelManualInput                 = random.NextBoolean(),
                    AssessmentLevel        = random.NextRoundedDouble(),
                    SlipPlaneMinimumDepth  = random.NextRoundedDouble(),
                    SlipPlaneMinimumLength = random.NextRoundedDouble(),
                    MaximumSliceWidth      = random.NextRoundedDouble(),
                    MoveGrid                                = random.NextBoolean(),
                    DikeSoilScenario                        = random.NextEnumValue <MacroStabilityInwardsDikeSoilScenario>(),
                    WaterLevelRiverAverage                  = random.NextRoundedDouble(),
                    DrainageConstructionPresent             = random.NextBoolean(),
                    XCoordinateDrainageConstruction         = random.NextRoundedDouble(),
                    ZCoordinateDrainageConstruction         = random.NextRoundedDouble(),
                    MinimumLevelPhreaticLineAtDikeTopRiver  = random.NextRoundedDouble(),
                    MinimumLevelPhreaticLineAtDikeTopPolder = random.NextRoundedDouble(),
                    LocationInputExtreme                    =
                    {
                        WaterLevelPolder  = random.NextRoundedDouble(),
                        UseDefaultOffsets = random.NextBoolean(),
                        PhreaticLineOffsetBelowDikeTopAtRiver     = random.NextRoundedDouble(),
                        PhreaticLineOffsetBelowDikeTopAtPolder    = random.NextRoundedDouble(),
                        PhreaticLineOffsetBelowShoulderBaseInside = random.NextRoundedDouble(),
                        PhreaticLineOffsetBelowDikeToeAtPolder    = random.NextRoundedDouble(),
                        PenetrationLength                         = random.NextRoundedDouble()
                    },
                    LocationInputDaily                            =
                    {
                        WaterLevelPolder  = random.NextRoundedDouble(),
                        UseDefaultOffsets = random.NextBoolean(),
                        PhreaticLineOffsetBelowDikeTopAtRiver     = random.NextRoundedDouble(),
                        PhreaticLineOffsetBelowDikeTopAtPolder    = random.NextRoundedDouble(),
                        PhreaticLineOffsetBelowShoulderBaseInside = random.NextRoundedDouble(),
                        PhreaticLineOffsetBelowDikeToeAtPolder    = random.NextRoundedDouble()
                    },
                    AdjustPhreaticLine3And4ForUplift     = random.NextBoolean(),
                    LeakageLengthOutwardsPhreaticLine3   = random.NextRoundedDouble(),
                    LeakageLengthInwardsPhreaticLine3    = random.NextRoundedDouble(),
                    LeakageLengthOutwardsPhreaticLine4   = random.NextRoundedDouble(),
                    LeakageLengthInwardsPhreaticLine4    = random.NextRoundedDouble(),
                    PiezometricHeadPhreaticLine2Outwards = random.NextRoundedDouble(),
                    PiezometricHeadPhreaticLine2Inwards  = random.NextRoundedDouble(),
                    GridDeterminationType        = random.NextEnumValue <MacroStabilityInwardsGridDeterminationType>(),
                    TangentLineDeterminationType = random.NextEnumValue <MacroStabilityInwardsTangentLineDeterminationType>(),
                    TangentLineZTop    = random.NextRoundedDouble(2.0,                                                    3.0),
                    TangentLineZBottom = random.NextRoundedDouble(0.0,                                                    1.0),
                    TangentLineNumber  = random.Next(1,                                                                    50),
                    LeftGrid           =
                    {
                        XLeft  = random.NextRoundedDouble(0.0,                                                                   1.0),
                        XRight = random.NextRoundedDouble(2.0,                                                                   3.0),
                        NumberOfHorizontalPoints                  = random.Next(1,                                                                                  100),
                        ZTop    = random.NextRoundedDouble(2.0,                                                                   3.0),
                        ZBottom = random.NextRoundedDouble(0.0,                                                                   1.0),
                        NumberOfVerticalPoints                    = random.Next(1,                                     100)
                    },
                    RightGrid                                     =
                    {
                        XLeft  = random.NextRoundedDouble(0.0,                                                                   1.0),
                        XRight = random.NextRoundedDouble(),
                        NumberOfHorizontalPoints                  = random.Next(1,                                                                                  100),
                        ZTop    = random.NextRoundedDouble(2.0,                                                                   3.0),
                        ZBottom = random.NextRoundedDouble(0.0,                                                                   1.0),
                        NumberOfVerticalPoints                    = random.Next(1,                                   100)
                    },
                    CreateZones                                   = random.NextBoolean(),
                    ZoningBoundariesDeterminationType             = random.NextEnumValue <MacroStabilityInwardsZoningBoundariesDeterminationType>(),
                    ZoneBoundaryLeft  = random.NextRoundedDouble(),
                    ZoneBoundaryRight = random.NextRoundedDouble()
                }
            };

            var registry = new PersistenceRegistry();
            int order    = random.Next();

            // Call
            MacroStabilityInwardsCalculationEntity entity = scenario.Create(registry, order);

            // Assert
            Assert.IsNotNull(entity);

            MacroStabilityInwardsCalculationEntityTestHelper.AssertCalculationScenarioPropertyValues(scenario, entity);
            Assert.IsNull(entity.SurfaceLineEntity);
            Assert.IsNull(entity.MacroStabilityInwardsStochasticSoilProfileEntity);
            Assert.IsNull(entity.HydraulicLocationEntity);
            Assert.AreEqual(order, entity.Order);
        }