public void Read_EntityWithOutput_ReturnsCalculationScenarioWithOutput()
        {
            // Setup
            var random       = new Random(31);
            var tangentLines = new RoundedDouble[0];
            var slices       = new MacroStabilityInwardsSlice[0];

            var calculationOutputEntity = new MacroStabilityInwardsCalculationOutputEntity
            {
                SlipPlaneTangentLinesXml = new TangentLineCollectionXmlSerializer().ToXml(tangentLines),
                SlidingCurveSliceXML     = new MacroStabilityInwardsSliceCollectionXmlSerializer().ToXml(slices),
                SlipPlaneLeftGridNrOfHorizontalPoints  = random.Next(1, 100),
                SlipPlaneLeftGridNrOfVerticalPoints    = random.Next(1, 100),
                SlipPlaneRightGridNrOfHorizontalPoints = random.Next(1, 100),
                SlipPlaneRightGridNrOfVerticalPoints   = random.Next(1, 100)
            };

            MacroStabilityInwardsCalculationEntity entity = CreateValidCalculationEntity();

            entity.MacroStabilityInwardsCalculationOutputEntities.Add(calculationOutputEntity);

            var collector = new ReadConversionCollector();

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

            // Assert
            MacroStabilityInwardsOutput output = calculation.Output;

            Assert.IsNotNull(output);
            MacroStabilityInwardsCalculationOutputEntityTestHelper.AssertOutputPropertyValues(output, calculationOutputEntity);
        }
        public void Read_EntityWithValues_ReturnExpectedOutput()
        {
            // Setup
            var random = new Random(21);
            IEnumerable <MacroStabilityInwardsSlice> slices = new[]
            {
                MacroStabilityInwardsSliceTestFactory.CreateSlice()
            };
            IEnumerable <RoundedDouble> tangentLines = new[]
            {
                new RoundedDouble(2, random.NextDouble())
            };

            var entity = new MacroStabilityInwardsCalculationOutputEntity
            {
                FactorOfStability       = random.NextDouble(),
                ForbiddenZonesXEntryMin = random.NextDouble(),
                ForbiddenZonesXEntryMax = random.NextDouble(),
                SlidingCurveSliceXML    = new MacroStabilityInwardsSliceCollectionXmlSerializer().ToXml(slices),
                SlidingCurveNonIteratedHorizontalForce         = random.NextDouble(),
                SlidingCurveIteratedHorizontalForce            = random.NextDouble(),
                SlidingCurveLeftSlidingCircleCenterX           = random.NextDouble(),
                SlidingCurveLeftSlidingCircleCenterY           = random.NextDouble(),
                SlidingCurveLeftSlidingCircleRadius            = random.NextDouble(),
                SlidingCurveLeftSlidingCircleIsActive          = Convert.ToByte(random.NextBoolean()),
                SlidingCurveLeftSlidingCircleNonIteratedForce  = random.NextDouble(),
                SlidingCurveLeftSlidingCircleIteratedForce     = random.NextDouble(),
                SlidingCurveLeftSlidingCircleDrivingMoment     = random.NextDouble(),
                SlidingCurveLeftSlidingCircleResistingMoment   = random.NextDouble(),
                SlidingCurveRightSlidingCircleCenterX          = random.NextDouble(),
                SlidingCurveRightSlidingCircleCenterY          = random.NextDouble(),
                SlidingCurveRightSlidingCircleRadius           = random.NextDouble(),
                SlidingCurveRightSlidingCircleIsActive         = Convert.ToByte(random.NextBoolean()),
                SlidingCurveRightSlidingCircleNonIteratedForce = random.NextDouble(),
                SlidingCurveRightSlidingCircleIteratedForce    = random.NextDouble(),
                SlidingCurveRightSlidingCircleDrivingMoment    = random.NextDouble(),
                SlidingCurveRightSlidingCircleResistingMoment  = random.NextDouble(),
                SlipPlaneTangentLinesXml = new TangentLineCollectionXmlSerializer().ToXml(tangentLines),
                SlipPlaneLeftGridXLeft   = random.NextDouble(0.0, 1.0),
                SlipPlaneLeftGridXRight  = random.NextDouble(2.0, 3.0),
                SlipPlaneLeftGridNrOfHorizontalPoints = random.Next(1, 100),
                SlipPlaneLeftGridZTop                  = random.NextDouble(2.0, 3.0),
                SlipPlaneLeftGridZBottom               = random.NextDouble(0.0, 1.0),
                SlipPlaneLeftGridNrOfVerticalPoints    = random.Next(1, 100),
                SlipPlaneRightGridXLeft                = random.NextDouble(0.0, 1.0),
                SlipPlaneRightGridXRight               = random.NextDouble(2.0, 3.0),
                SlipPlaneRightGridNrOfHorizontalPoints = random.Next(1, 100),
                SlipPlaneRightGridZTop                 = random.NextDouble(2.0, 3.0),
                SlipPlaneRightGridZBottom              = random.NextDouble(0.0, 1.0),
                SlipPlaneRightGridNrOfVerticalPoints   = random.Next(1, 100)
            };

            // Call
            MacroStabilityInwardsOutput output = entity.Read();

            // Assert
            MacroStabilityInwardsCalculationOutputEntityTestHelper.AssertOutputPropertyValues(output, entity);
        }
        public void Read_EntityWithNullValues_ReturnExpectedOutputWithNaNValues()
        {
            // Setup
            MacroStabilityInwardsCalculationOutputEntity entity = CreateValidCalculationOutputEntity();

            // Call
            MacroStabilityInwardsOutput output = entity.Read();

            // Assert
            MacroStabilityInwardsCalculationOutputEntityTestHelper.AssertOutputPropertyValues(output, entity);
        }
        public void Create_HasMacroStabilityInwardsOutput_ReturnsEntityWithOutputEntity()
        {
            // Setup
            var scenario = new MacroStabilityInwardsCalculationScenario
            {
                Output = MacroStabilityInwardsOutputTestFactory.CreateOutput()
            };

            var registry = new PersistenceRegistry();

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

            // Assert
            Assert.IsNotNull(entity);
            MacroStabilityInwardsCalculationOutputEntity outputEntity = entity.MacroStabilityInwardsCalculationOutputEntities.SingleOrDefault();

            Assert.IsNotNull(outputEntity);
            MacroStabilityInwardsCalculationOutputEntityTestHelper.AssertOutputPropertyValues(scenario.Output, outputEntity);
        }
        public void Create_WithValidValues_ReturnsEntityWithExpectedPropertiesSet()
        {
            // Setup
            var random = new Random(21);

            MacroStabilityInwardsSlidingCircle leftCircle = CreateSlidingCircle(13);
            MacroStabilityInwardsSlidingCircle rightCircle = CreateSlidingCircle(34);
            IEnumerable<MacroStabilityInwardsSlice> slices = new[]
            {
                MacroStabilityInwardsSliceTestFactory.CreateSlice()
            };
            var slidingCurve = new MacroStabilityInwardsSlidingCurve(leftCircle,
                                                                     rightCircle,
                                                                     slices,
                                                                     random.NextDouble(),
                                                                     random.NextDouble());

            MacroStabilityInwardsGrid leftGrid = MacroStabilityInwardsGridTestFactory.Create();
            MacroStabilityInwardsGrid rightGrid = MacroStabilityInwardsGridTestFactory.Create();
            RoundedDouble[] tangentLines =
            {
                random.NextRoundedDouble()
            };
            var slipPlane = new MacroStabilityInwardsSlipPlaneUpliftVan(leftGrid, rightGrid, tangentLines);

            var output = new MacroStabilityInwardsOutput(slidingCurve, slipPlane, new MacroStabilityInwardsOutput.ConstructionProperties
            {
                FactorOfStability = random.NextDouble(),
                ForbiddenZonesXEntryMax = random.NextDouble(),
                ForbiddenZonesXEntryMin = random.NextDouble()
            });

            // Call
            MacroStabilityInwardsCalculationOutputEntity entity = output.Create();

            // Assert
            Assert.IsNotNull(entity);
            MacroStabilityInwardsCalculationOutputEntityTestHelper.AssertOutputPropertyValues(output, entity);
        }